IsNavigationTarget never gets called for TabControl region.

Topics: Prism v4 - Silverlight 4
Oct 30, 2010 at 8:41 AM
Edited Oct 30, 2010 at 8:41 AM

When a TabControl region is the target for navigation, I expected all of the existing tab item views/view-models to be queried if they implemented INavigationAware. This does not seem to be the case.

I am using Prism v4 Drop 10 and MEF in my navigation scenario. My TestTabView, a UserControl, has attributes:

 

[Export("TestTab")]
[PartCreationPolicy(System.ComponentModel.Composition.CreationPolicy.NonShared)]

 

I navigate to it like this:

 

regionManager.Regions[ShellRegions.Tabs].RequestNavigate("/TestTab");

 

This works, except every time I call RequestNavigate, a new TestTabView is created and the existing one is never queried via INavigationAware.IsNavigationTarget. The TestTabViewModel also implements INavigationAware and it is not queried either. I also tried changing to CreationPolicy.Shared, but all that does is keep re-using the same view instance and the INavigationAware.IsNavigationTarget is still not queried on the view or view-model.

Any suggestions? The quickstart only shows a ContentControl navigation example.

Oct 30, 2010 at 8:43 AM

The overall scenario that I'm trying to implement is documented in another thread - http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=232599

Oct 31, 2010 at 9:51 AM

Figured out the problem. [Export("TestTab")] had to be changed to [Export("TestTabView")] so that the name of the contract matched the name of the class type.

More details in a comment on this related issue - http://compositewpf.codeplex.com/workitem/7468

Nov 2, 2010 at 8:12 PM

Hi Wayne,

I am glad that you figured out the problem in your scenario. Based on this information, I assume that the work-item 7468 can be closed.

Please let me know if you have any other question.

Fernando Antivero
http://blogs.southworks.net/fantivero

Nov 2, 2010 at 10:51 PM

Well, no I don't think it should be closed because there is still a bug.

According to the documentation, the navigation string does not have to be the same as the type name. However in that issue I have shown that it DOES have to be the type name in order for the INavigationAware.IsNavigationTarget method to get called at all.