Using MVVMP with navigation

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
Dec 27, 2011 at 12:16 PM


I am using the MVVMP pattern, which I find superior to MVVM.
Following my preseneter constrcutor

public MainPresenter(IMainView view) {
viewModel = new MainViewModel ();
this.view = view;

Registration of view done in the following way


I would like to support "navigation" to presenters using same way prism does for view and view model
My view and my view model doesnot hold a reference to the presenter
Both must  not implement INavigationAware
I also dont want to declare navigation events in IMainView so the presenter can handle them
And i need to pass parameters(objects) between presenters

Looks like i need some application controller which tracks active presenters.

What would be the best way to do it?
Thanks in advance


Dec 27, 2011 at 4:31 PM


This is my first try without handling re activation, the view displayed but command not get called

If i am casting IView to UserControl i also dont get the Loaded event!!

public static void ActivatePresenter(this IRegionManager manager , string regionName,string presenterName)
           IUnityContainer container = ServiceLocator.Current.GetInstance<IUnityContainer>();

           IPresenter presenter = container.Resolve<IPresenter>(presenterName);

           IView view = presenter.View;

           manager.RegisterViewWithRegion(regionName, view.GetType());


           presenter.Activate();//should be called after the View is loaded

in presenter:

 public void Activate()
            viewModel.UpdateReportPropertiesCommand = new DelegateCommand(LoadReport);
            this.View.DataContext = viewModel;


Dec 27, 2011 at 4:50 PM

ok,it is working now,i should use


when registering the view type in the container


Dec 27, 2011 at 6:27 PM


As far as I know, the Prism Library is intended to be neutral respecting the choice of separated UI patterns. You can be successful with any of the available patterns, although considering the facilities in WPF and Silverlight for data binding, commands, and behaviors, the MVVM pattern is the recommended approach. Based on this, Prism (as out of the box) provides navigation functionality focusing on the case where the application is using the MVVM pattern.

For the MVVMP pattern case, the implementation details for capabilities you describe above will depend mostly of your personal preferences and the requirements of your scenario.

Based on my understanding, as a possible approach you might be able to perform navigation using a kind of "presenter first approach":

For example, instead of registering the view for navigation, you could register the presenter doing something like this:

// We register the MainPresenter instead of its view.
Container.RegisterType<Object, MainPresenter>("MainPresenter");

// Then we invoke a navigation request like usual.
regionManager.RequestNavigate("MyRegion", new Uri("MyPresenter", UriKind.Relative));

When the navigation request is performed, the MainPresenter presenter will be injected in the region instead of its view. Then, in the aforementioned region, you could take benefit for the capabilities of DataTemplates, and create a binding to the View property of the presenter, for example:

<ContentControl prism:RegionManager.RegionName="MyRegion" >
        <DataTemplate DataType="infra:IPresenter">
            <ContentControl Content="{Binding Path=View}"/>

Like this, the presenter will be in charge of creating its view and view model, wiring them together and exposing its View.

As a possible approach to communicate between presenters, you could use a Shared Service that could be obtained though the container. You can find more information about communication between components in the following chapter of the prism documentation:

Also, you can pass parameters to the presenter when performing the navigation request, like you would do with a view.

As a side note, take into account that there is a known issue in Prism, where if a visual element containing a region is not part of the logical tree of the control (this can happen, for example, when using DataTemplates), the region might not be registered in the corresponding RegionManager. You can find more information about this issue, as well as various workarounds in the following work item:

I hope you find this useful,

Damian Cherubini

Dec 27, 2011 at 6:45 PM


Awesome,Thanks! Actually it was my first attempt, but I thought I need to implement custom


In order to bring the content (view) out of the presenter.

It is just that I am not too experience with WPF so i didnt even think about using xaml

Presenter first is indeed my preferred approach.

I prefere passing paramaters using the INavigationAware

I will try it.

Thanks for the info,helped me a lot,