How to use "controller" template in prism app

Topics: Prism v4 - Silverlight 4
Nov 14, 2011 at 7:21 AM
Edited Nov 14, 2011 at 7:29 AM

 Hi! I created a prism design. It includes 3 of the project: Module A, Module B and ControllerModule.
The controller contains a reference to modules A and B.

In the constructor of the controller creates a subscription to an event "TestEvent".

_eventAggregator.GetEvent<TestEvent>().Subscribe(Test,true );

The event "TestEvent" is initialized in the module A.


Also, the controller defined an event handler "Test".

private void Test(object obj)
IRegion actionRegion = _regionManager.Regions["MainListRegion" ];

if (actionRegion != null )

MainListView mainListView = actionRegion.GetView("MainListView ") as MainListView ;

if (twitListView == null )


mainListView= _container.Resolve<MainListView >();

actionRegion.Add(mainListView,"TwitListView" );


((MainListViewModel)mainListView.DataContext).Text = obj.ToString();

actionRegion.NavigationService.RequestNavigate("MainListView " );


Everything seems to work. But I can not understand why the property is not set Text! That is no data Show in Module A.

Tell me please how to change the property of the controller module A?

Nov 14, 2011 at 5:11 PM


There are various factors that could produce the behavior you are experiencing. For example, it's possible that the Text property is being set correctly, but that your view is not being notified of this change. To notify the view of a property change in the view model you could implement the INofityPropertyChanged interface in the view model and raise the PropertyChanged event in the setter of the Text property. Also, you might find useful to inherit your view model from the NotificationObject class as it provides an implementation of the aforementioned interface.

Another possibility is that the Text property is being set correctly, but when you call the RequestNavigate method that view is removed or deactivated from the region and a new instance of the view (the one you exported with the "MainListView" name) is created. This new instance might have different view model with its own Text property. You can find more information about this here:

I hope you find this useful,

Damian Cherubini

Nov 15, 2011 at 5:13 AM

In my project implements the interface INotifyPropertyChanged. But sorry to change the properties of the text is not happening!

If you use a smart module "Controller" in which the subscription to all events and will be processed, then "Controller" can not change the properties of another module in the processing of events.

And if you handle the event in the unit where you want to change the properties of all the works fine!

Nov 15, 2011 at 5:25 PM


If you are still experiencing this undesired behavior, it would be useful if you could provide us with a repro-sample application portraying this problem so we can help you find the cause behind it.

You can upload it, for example, to Skydrive or to another web storage service of your preference.


Damian Cherubini