This project has moved and is read-only. For the latest updates, please go here.

binding properties between viewmodels?

Apr 8, 2010 at 8:31 AM


how would you bind notify-able properties between viewmodels? 

say i have 2 viewmodels that exposes properties.

i would like to do a binding operation between both viewmodels and would like put the binding code elsewhere like some ViewModelsBinding.cs file where i specify all bindings across viewmodels

is it good practice to do that?

Apr 8, 2010 at 12:33 PM

I would use messaging to communicate between view models.  See for an example.

If that doesn't answer your question, please give a more detailed description of what you're trying to accomplish.

Apr 8, 2010 at 3:53 PM
Edited Apr 8, 2010 at 3:53 PM


yeah, i know there is the messenger. But i would like the twoway binding/capability. so whenever one of the viewmodels modifies the property, the other would be updated as well.

and i also would like know if it is possible to have a .cs file that specifies all the bindings between viewmodels instead of putting the binding code in the viewmodel.. just want to know if it is good practice?


Apr 8, 2010 at 4:08 PM

After reading these details, my initial thought is wondering why these are separate views.

I don't know that I've seen any guidance on MVVM where you have disparate views data bound to each other's values.

You could also try creating a global view model and using the ViewModelLocator to set the data context of individual elements that need to bind to values from that view model.

May 17, 2010 at 8:20 PM

I can think of exactly the reason. Right now I have a three-pane UI design where the first pane is bound to the "shell" viewmodel, the second pane selects that subset of data to edit, and the third pane lets you actually edit the data. The way I have it wired currently, the 2nd pane has TreeView containing TreeItems with Tags that point to the XAML page to load, and the 3rd panel is a Frame that dynamically loads and presents the Ui to the user.

I have the different ViewModels working separately, but now I need to be able to pass the selected item in the TreeView in the first pane to the ObjectSource property in the ViewModel for the 3rd pane (or setting selected sets a property in the "shell window" ViewModel, which the 3rd pane ViewModel could bind to.


May 17, 2010 at 11:48 PM


I developed the Messenger exactly for this kind of scenarios. I would really recommend you take a good look at it, it is made to enable loosely coupled communication between viewmodels (and other objects as well).