User.Resources in ViewModel

Topics: Prism v4 - Silverlight 4
Jan 7, 2011 at 9:33 AM

Hi Guys,

 

Currently i m converting my application to PRISM 4 MVVM. In my old application xaml file i have some UserControl.Resources. How can i bring them to my ViewModel Class.??

 

thnx-

Developer
Jan 7, 2011 at 4:59 PM

Hi,

When you add an object to the Resources of your UserControl, if you specify a name for it through the x:Name property, it will be available in your code behind. You could have your ViewModel obtain them through a reference to your view.

However, take into account that it's not recommended for the ViewModel to be aware of the view, so the recommended practice would be to directly place those resources as properties in your ViewModel, and bind to them in your view.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi