Reputation: 527
I have two resource dictionaries
- DarkTheme.xaml
- LightTheme.xaml
I load the LightTheme
by default when the application starts in app.xaml file using the following code
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes/LightTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
I want to give an option to user that he can change the theme of application as he likes problem is that how can i load the DarkTheme.xaml
file when user chooses that theme and load LightTheme.xaml
file when it is chosen.
Upvotes: 1
Views: 770
Reputation: 9827
Application.Current.Resources.MergedDictionaries[0] =
new ResourceDictionary() { Source = new Uri("Themes/LightTheme.xaml", UriKind.Relative) };
Upvotes: 2