From cb24ed56228a6784fe43cf1cb550491ea15da6dc Mon Sep 17 00:00:00 2001 From: Mahdi Hosseini Date: Thu, 6 Jul 2023 14:09:09 +0330 Subject: [PATCH] UpdateCaptionButtons --- components/TitleBar/src/TitleBar.WASDK.cs | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/components/TitleBar/src/TitleBar.WASDK.cs b/components/TitleBar/src/TitleBar.WASDK.cs index 38dced2f8..7cd360ed1 100644 --- a/components/TitleBar/src/TitleBar.WASDK.cs +++ b/components/TitleBar/src/TitleBar.WASDK.cs @@ -46,8 +46,14 @@ private void SetWASDKTitleBar() this.Window.Activated -= Window_Activated; this.Window.Activated += Window_Activated; - appWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; - appWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; + if (Window.Content is FrameworkElement rootElement) + { + UpdateCaptionButtons(rootElement); + rootElement.ActualThemeChanged += (s, e) => + { + UpdateCaptionButtons(rootElement); + }; + } // Set the width of padding columns in the UI. PART_ButtonsHolderColumn = GetTemplateChild(nameof(PART_ButtonsHolderColumn)) as ColumnDefinition; @@ -82,6 +88,22 @@ private void SetWASDKTitleBar() } } + private void UpdateCaptionButtons(FrameworkElement rootElement) + { + appWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; + appWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; + if (rootElement.ActualTheme == ElementTheme.Dark) + { + appWindow.TitleBar.ButtonForegroundColor = Colors.White; + appWindow.TitleBar.ButtonInactiveForegroundColor = Colors.DarkGray; + } + else + { + appWindow.TitleBar.ButtonForegroundColor = Colors.Black; + appWindow.TitleBar.ButtonInactiveForegroundColor = Colors.DarkGray; + } + } + private void ResetWASDKTitleBar() { if (this.Window == null)