wpf - Dynamically change implicit style -


I now have some tabs in my app that are styled mutually. I want to add my app "night mode" and change my style. How should I go about this?

You can do all your "normal" styles in a dictionary with merged dictionaries Keep it in the app resources by default:

  & lt; application. Resources & gt; & Lt; ResourceDictionary & gt; & Lt; ResourceDictionary.MergedDictionaries & gt; & Lt; Source Source = "Styles / Normal.xml" /> & Lt; /ResourceDictionary.MergedDocs> & Lt; / ResourceDictionary & gt; & Lt; /Application.Resources>   

Then you can remove the existing dictionary and load each other dynamically:

  Private Zero ChangeStyles () {App.Current.Resources.MergedDictionaries.Clear (); StreamResourceInfo resInfo = App.GetResourceStream (new Uri ("Styles / New Style .xml", Uricund.Relative)); XDocument xaml = XDocument.Load (resInfo.Stream); ResourceDictionary resource = XamlReader.Load (xaml.ToString ()) as ResourceDictionary; App.Current.Resources.MergedDictionaries.Add (Resources); }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -