In the UI, I apply the dark theme. While ComboBoxes in normal grid switch to dark theme, ComboBoxes in DialogHost do not switch to dark theme.
materialDesign: ColorZoneAssist.Mode ="Dark" when I apply this, dark mode is applied. But I want a structure that can change dynamically, not like this.
My theme application code is as follows.
public void SetLightDark(bool isDark)
{
var resources = Application.Current.Resources.MergedDictionaries;
var existingResourceDictionary = Application.Current.Resources.MergedDictionaries
.Where(rd => rd.Source != null)
.SingleOrDefault(rd => Regex.Match(rd.Source.OriginalString, @"(\/Themes\/MaterialDesign((Light)|(Dark))Theme)").Success);
var source = $"pack://application:,,,/Themes/MaterialDesign{(isDark ? "Dark" : "Light")}Theme.xaml";
var newResourceDictionary = new ResourceDictionary() { Source = new Uri(source) };
Application.Current.Resources.MergedDictionaries.Remove(existingResourceDictionary);
Application.Current.Resources.MergedDictionaries.Add(newResourceDictionary);
}
If you are on a version prior to 4.0.0 the default theme of the dialog host defaults to the light these. This was fixed in the 4.0.0 release so that it will properly inherit the application theme. If you are on a version prior to 4.0.0 you can change the DialogTheme property of your DialogHost to be Inherit and that will give you the same behavior.
There is a slightly easier way to do the theming of your app. In version 2.6.0 there was a new theming API that was introduced that lets you manage it in a much more code friendly way. This is documented in the wiki and you can see an example of it in action in the demo app here and here.
Hello,
In the UI, I apply the dark theme. While ComboBoxes in normal grid switch to dark theme, ComboBoxes in DialogHost do not switch to dark theme.
materialDesign: ColorZoneAssist.Mode ="Dark"
when I apply this, dark mode is applied. But I want a structure that can change dynamically, not like this.My theme application code is as follows.
How can I solve this problem.