XAML – Retrieve the value from the resourceDictionary in the later code

I have a Windows 10 universal application, which contains some resource dictionaries for styling, etc.
In a resource dictionary like this, I have a color MyBlue, and I want Access through the code behind. How is this achieved?

I tried .Resources [“MyBlue”], but since MyBlue is defined in a separate resource dictionary instead of directly in the page resource, it does not exist in this collection .

This is my app.xaml:











< br /> d:IsDataSource="True"/>


< /ResourceDictionary>

do you have Tried

Application.Current.Resources["MyBlue"]

I have a Windows 10 universal application which contains some resource dictionaries for styling etc.
In such a resource dictionary, I have a color MyBlue, which I want to access through the code behind. How is this achieved?

I tried .Resources [“MyBlue”], but since MyBlue is defined in a separate resource dictionary instead of directly in the page resource, it does not exist in this collection .

This is my app.xaml:











< br /> d:IsDataSource="True"/>


< /ResourceDictionary>

Have you tried

Application.Current.Resources["MyBlue"]

< p>

Leave a Comment

Your email address will not be published.