Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get style in code from resource dictionary?

If you put style in app.xmal, then you can get the style with the code like:

Style = Application.Current.Resources["myStyle"] as Style;

But if I put style in a dictionary resource of a separate file Styles.xmal like:

 <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>                
                <ResourceDictionary Source="Assets/Styles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

Then how to get the style in code?

like image 211
KentZhou Avatar asked Aug 13 '09 17:08

KentZhou


1 Answers

Found out reason: code

Style = Application.Current.Resources["myStyle"] as Style;

works fine. My problem is caused by some other factors.

like image 98
KentZhou Avatar answered Oct 24 '22 01:10

KentZhou