User.Resources in ViewModel

Topics: Prism v4 - Silverlight 4
Jan 7, 2011 at 8: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.??



Jan 7, 2011 at 3:59 PM


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