Updating A View With Ribbon Button

Topics: Prism v4 - WPF 4
Aug 10, 2012 at 9:27 PM
Edited Aug 10, 2012 at 9:32 PM

I am hitting a brick wall and cannot grasp the idea of this. I am just starting in using the MVVM and Prism.

I have a shell with two regions, my ribbonRegion and the mainRegion. I am trying to figure out how to even do the simplest update to my view in the mainRegion from a button click in a view in the ribbonRegion. Say, click a button and change the text on the view from 'My Text' to 'Hello World'.

So, obviously you tie the view in the ribbionRegion to a view model and therein tie the button click command to a delegate command right? Well, how do I have that command update something on the main view model and ultimately the main view? It is in the same module, just a different region. I should be able to so that without using eventAggregator, shouldn't I?

I've read through many tutorials and the Prism dev guide, but they are all overly complicated, so I can't figure out what exactly needs to happen. I just want to know the basics of how to get it to work.

Aug 13, 2012 at 2:00 PM
Edited Aug 13, 2012 at 2:02 PM


Based on my understanding , the aforementioned approach seems to be right, the only thing you may be missing is that to ensure that the UI is kept up to date when the data changes in your view model, you should implement the appropriate change notification interface. For example if you bind a value in your view  to a property exposed in your view model that could be changed when clicking a button, your view model should implement the INotifyPropertyChanged interface, which defines an event that is raised whenever the underlying data is changed, in order to notify the UI about the changes.

You will find that the Prism Library provides a convenient base class (NotificationObject) that implements the INotifyPropertyChanged interface, from which you can derive your view model classes. This way your view model can raise the property change event by either invoking RaisePropertyChanged with the property name specified or using a lambda expression that refers to the property for example like this:

//Using property name

//Using lambda expression
this.RaisePropertyChanged(() => this.MyProperty);

You could find more information and examples in the following resources:

I hope you find this handy,

Agustin Adami

Aug 13, 2012 at 5:11 PM
Edited Aug 13, 2012 at 5:12 PM

Ah, everything is slowly starting to click. I am kind of trying to learn too much at once (moving from forms to WPF/MVVM/Prism), so it is taking me a little bit to really start thinking differently.

So, lets take this a step further...

So, I have a 'Load/Reload' button in my ribbonRegion. Upon clicking that, I invoke a service to retrieve the data, utilizing a shared service. Essentially, since the other region is using the shared service, once I reload data in that service, the 'mainRegion' is notified simply by a property change and updates accordingly, correct?

Aug 13, 2012 at 6:32 PM


Take into account that the RaisePropertyChanged is only used to communicate between your view and your view model. If you need to communicate from different views I believe you should use other communication approach like events.

For example in your scenario the view model of the view in your "mainRegion" could be subscribed to a custom event, so your shared service could publish/raise this event when the data is changed. Then in the handler of this event, you could retrieve the updated data from the Shared Service and set the property that exposes the information, also calling the RaisePropertyChanged in order to notify the UI properly.

I hope you find this helpful,

Agustin Adami