I have a Windows 10 universal app with a few resource dictionaries for styles and such.
In one such resource dictionary, I have a color, MyBlue
that I want to access via the code behind. How is this achieved?
I've tried this.Resources["MyBlue"]
, but since MyBlue
is defined in a separate resource dictionary and not directly in the page resources it doesn't exist in this collection.
Here's my app.xaml:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/PodStyles.xaml"/>
<ResourceDictionary Source="Styles/ButtonStyles.xaml"/>
<ResourceDictionary Source="Styles/OfferStyles.xaml"/>
<ResourceDictionary Source="Styles/MyStyles.xaml"/>
<ResourceDictionary>
<!--Global View Model Locator-->
<vm:ViewModelLocator x:Key="Locator"
d:IsDataSource="True"/>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Have you tried
Application.Current.Resources["MyBlue"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With