From c41d206ff14b79f2f5e6adbc4eaa6256096357ce Mon Sep 17 00:00:00 2001 From: seasonyuu Date: Wed, 13 Mar 2024 14:24:55 +0800 Subject: [PATCH 1/2] Fix mouse over color of TitleBarButton for TitleBarButtonType.Close --- src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml | 2 ++ .../Controls/TitleBar/TitleBarButton.cs | 26 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml b/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml index afdd69040..7ddcc3435 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml @@ -15,6 +15,7 @@ + @@ -193,6 +194,7 @@ x:Name="PART_CloseButton" Grid.Column="4" ButtonType="Close" + MouseOverButtonsForeground="White" MouseOverBackground="{DynamicResource PaletteRedBrush}" /> diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs index 876352858..e85dc4169 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBarButton.cs @@ -36,6 +36,19 @@ internal class TitleBarButton : Wpf.Ui.Controls.Button ) ); + /// + /// Property for . + /// + public static readonly DependencyProperty MouseOverButtonsForegroundProperty = DependencyProperty.Register( + nameof(MouseOverButtonsForeground), + typeof(Brush), + typeof(TitleBarButton), + new FrameworkPropertyMetadata( + SystemColors.ControlTextBrush, + FrameworkPropertyMetadataOptions.Inherits + ) + ); + /// /// Sets or gets the /// @@ -53,11 +66,20 @@ public Brush ButtonsForeground get => (Brush)GetValue(ButtonsForegroundProperty); set => SetValue(ButtonsForegroundProperty, value); } + /// + /// Foreground of the navigation buttons while mouse over. + /// + public Brush MouseOverButtonsForeground + { + get => (Brush)GetValue(MouseOverButtonsForegroundProperty); + set => SetValue(MouseOverButtonsForegroundProperty, value); + } public bool IsHovered { get; private set; } private User32.WM_NCHITTEST _returnValue; private Brush _defaultBackgroundBrush = Brushes.Transparent; //Should it be transparent? + private Brush _cacheButtonsForeground = SystemColors.ControlTextBrush; // cache ButtonsForeground while mouse over private bool _isClickedDown; @@ -70,6 +92,8 @@ public void Hover() return; Background = MouseOverBackground; + _cacheButtonsForeground = ButtonsForeground; + ButtonsForeground = MouseOverButtonsForeground; IsHovered = true; } @@ -82,6 +106,7 @@ public void RemoveHover() return; Background = _defaultBackgroundBrush; + ButtonsForeground = _cacheButtonsForeground; IsHovered = false; _isClickedDown = false; @@ -119,7 +144,6 @@ internal bool ReactToHwndHook(User32.WM msg, IntPtr lParam, out IntPtr returnInt RemoveHover(); return false; - case User32.WM.NCMOUSELEAVE: // Mouse leaves the window RemoveHover(); return false; From 17689b8ec0c76511aa531295f5ae5433187b4533 Mon Sep 17 00:00:00 2001 From: seasonyuu Date: Wed, 13 Mar 2024 14:30:02 +0800 Subject: [PATCH 2/2] Remove unused TitleBarButton mouse over trigger --- src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml b/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml index 7ddcc3435..04ba6cea8 100644 --- a/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml +++ b/src/Wpf.Ui/Controls/TitleBar/TitleBar.xaml @@ -46,9 +46,6 @@ - - - @@ -75,14 +72,6 @@ - - - - - - - -