Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: How to invoke view of another module from a view of one module

$
0
0
Hi,

Based on my understanding, modules can't communicate directly between them. So in my opinion, in order to accomplish this task you have two possible options:

1 - Use Navigation. This way, you could call the RequestNavigate method from the region manager to show a view from a another module like this:
regionManager.RequestNavigate("MainRegion", new Uri("YourView", UriKind.Relative));
Note that you only need to know both the region and the view names to navigate, so you don't require to have an explicit reference between the modules. Also, remember that in order to be able to navigate to a view in a region, that view should be registered in the container accordingly.

Like this in Unity:
container.RegisterType<object,YourView>("YourView");
Or like this in MEF:
[Export("YourView")]
publicpartialclass YourView : UserControl
2 - Inject EventAggregator to your ViewModels and use Publish and Subscribe methods to communicate between the modules.

For more information on Navigation and communicating between loosely coupled components, you can visit the following sections of the Prism documentation:
Hope this helps,

Federico Martinez
http://blogs.southworks.net/fmartinez

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>