Setting or modifying ThemeResource in code

后端 未结 5 654
野趣味
野趣味 2021-02-06 04:14

My questions is very specific to ThemeResources in a Windows 10 Store App. Unfortunately several things available in \"classic\" WPF are different or not available here.

5条回答
  •  不知归路
    2021-02-06 04:59

    In Windows 10, the name "Accent Color" is changed to "SystemControlHighlightAccentBrush", and it's a ThemeResource

    Example using it

    
    

    To override it, simply change value of it in App.xaml

    
        
    
    

    To switch, it's a little bit more difficult First, you need to set all the color for each theme in App.xaml

    
        
            
                
                    
                
                
                    
                
                
                    
                
            
        
    
    

    Then, in the page or in code behind, you set the corresponding theme

    
    

    or in C#

    TestTextBlock.RequestedTheme = ElementTheme.Dark;
    

提交回复
热议问题