Thank you very much for your help. I have studied the documentation and your example these days. In fact the way of using Event Aggregator thourgh the delegate command proved very successful. (Perhaps the best and only way until Prism 3)
Now I also understand how the RegionContext could be utilized to achieve the same thing but simpler. I think this feature is new to Prism 4, and I found it very useful and like to share it here:
The scenario is that you have a NavigationModule that has a button bound to a Delegate Command. When pressed it would navigate (if not existing then instantiate) a View within MainModule.
NavigationModule has no idea about the MainModule and we won't be using any global Composite Commands nor any global Event Aggregator. Its Pure magic. :)
For now I have switched back to Unity, with MEF its even simpler.
First you would make your ViewModel to implement INavigationAware. Three methods need to be implemented. Leave all empty but the IsNavigationtarget(..). This one should return false, so that everytime the command is called a new instance of the view is created.
Within the Initialize() of the MainModule you would have to register the type of the View.
Now that the view can be resolved by IoC, we can just make the call in the Delegate Command's method on NavigationModule, which has no idea about the View nor its region. It just says put that View I heard about in that region I heard about.
_regionManager.RequestNavigate("MainRegion", new Uri("ContactView", UriKind.Relative);
The IoC container does the magic, no need for composite commands nor any events. The Uri points to the view indirectly and the IoC can resolve the view on the MainModule's MainRegion, since the IsNavigationTarget() returns false, it would
in this case always create a new View in that region. A logic can be implemented in that IsNavigationTarget() to return true if the Id's are equal. In that case it would navigate to an existing view rather than creating a new one. Perfect for TabControl scenarios.
I hope this helps someone else, and if I am wrong with anything please correct me.
I still have another Navigation related question for you. I do understand how the Confirmation/Cancellation works. But it seems to be only connected with Navigation, hence you get a chance to cancel or confirm when navigating away. However what if I
wanted to add the confirmation to the CloseButton I have created on each TabItem? The summary says:
1.Navigation operation is initiated via a RequestNavigate call.
What do you suggest? Is there any other pattern implemented for this or do I have to write my own?