Change theme at runtime

前端 未结 5 838
一向
一向 2020-11-30 01:48

I have a WPF application with a theme (ShinyRed.xaml) and I want to have a button that when clicked changes the theme to ShinyBlue.xaml

I load in the theme initially

5条回答
  •  我在风中等你
    2020-11-30 02:35

    App.xaml

        
        
            
                
                
            
        
    
    

    In your code:

    > Application.Current.Resources.MergedDictionaries[1].Source = new Uri("Themes/Dark.xaml", UriKind.RelativeOrAbsolute);
    

    you can check with this to be sure nothing grow

    Application.Current.Resources.MergedDictionaries.Count.ToString();

提交回复
热议问题