Hi you can have a static class like this below, this static class will have the reference of your resourceDIctionary, through this you can access the resources in the resource dictionary from your viewmodel.
internal static class SharedResourceDictionary
{
internal static ResourceDictionary SharedDictionary
{
get
{
if (_sharedDictionary == null)
{
try
{
System.Uri resourceLocater1 = new System.Uri(
string.Format("/{0};component/YourResourceDictionary.xaml",
"YourProject"), System.UriKind.Relative);
ResourceDictionary resourceDictionary = new ResourceDictionary
{
Source = resourceLocater1
};
_sharedDictionary = resourceDictionary;
}
catch (Exception e)
{
}
}
return _sharedDictionary;
}
}
private static ResourceDictionary _sharedDictionary;
}
You can get the resources from the viewmodel like this.
Ex:
ResourceDictionary resourceDictionary = (ResourceDictionary)SharedResourceDictionary.SharedDictionary;
LinearGradientBrush brush = (LinearGradientBrush)resourceDictionary["ButtonNormalBackground"];