From 704fcdfe3131df5a0a91ff03c9c4edf6423cedcc Mon Sep 17 00:00:00 2001 From: Dominik Titl <78549750+morning4coffe-dev@users.noreply.github.com> Date: Wed, 15 Jan 2025 15:05:08 +0100 Subject: [PATCH] docs: Update Working with Themes --- doc/articles/features/working-with-themes.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/articles/features/working-with-themes.md b/doc/articles/features/working-with-themes.md index 6b1f2acd42ea..ccac8943c0a6 100644 --- a/doc/articles/features/working-with-themes.md +++ b/doc/articles/features/working-with-themes.md @@ -67,9 +67,9 @@ public class MainPage : Page private void OnThemeChanged(ThemeListener sender) { - bool isDarkMode = sender.CurrentTheme == ApplicationTheme.Dark; + var theme = SystemThemeHelper.IsRootInDarkMode(this.XamlRoot) ? ElementTheme.Light : ElementTheme.Dark; - SystemThemeHelper.SetApplicationTheme(darkMode: isDarkMode); + SystemThemeHelper.SetApplicationTheme(this.XamlRoot, theme); } } ``` @@ -94,12 +94,14 @@ public class SettingsPage : Page private void OnLoaded(object sender, RoutedEventArgs e) { - this.DarkModeToggle.IsOn = SystemThemeHelper.IsDarkModeEnabled; + this.DarkModeToggle.IsOn = SystemThemeHelper.IsRootInDarkMode(this.XamlRoot); } private void OnDarkModeToggleToggled(object sender, RoutedEventArgs e) { - SystemThemeHelper.SetApplicationTheme(darkMode: this.DarkModeToggle.IsOn); + var theme = DarkModeToggle.IsOn ? ElementTheme.Light : ElementTheme.Dark; + + SystemThemeHelper.SetApplicationTheme(this.XamlRoot, theme); } } ```