I have a solution in which I have a Windows Phone App project and a ClassLibrary that itself has TemplatedControl.cs whose default style is referenced in the ClassLibrary/Themes/Generic.xaml Resource Dictionary.
- MySolution
- WPApp_Project
- MainPage.xaml/MainPage.xaml.cs
- App.xaml/App.xaml.cs
- ClassLibrary_Project
- Themes
- Generic.xaml
- View
- TemplatedControl.cs
- ViewModel
- TemplatedViewModel.cs
- ViewModelLocator.cs
For instance, I defined this in the Generic.xaml file:
<SolidColorBrush x:Key="MyBrush" Color="Gold"/>
How can I, from my WP App, change the value of this SolidColorBrush to an extent that it affects every element in my ClassLibrary that uses this Resource?
I managed to find a way to do this. Since I have a
TemplatedViewModel.cswith properties attached to it in myGeneric.xamlI basically created extra properties for the things I want to change, i.e., if I want to change the color of a TextBlock, I add the following in myGeneric.xaml:And in my WPApp I get an instance of my
TemplatedViewModel.csand set it to a new color:Ideally I would like to be able to set properties in a
ResourceDictionaryin XAML, however I wasn't able to. So for the next few days if someone can tell me how to that, I'll mark their reply as the answer.