From 437b454c838e7cfb0e0174d7024618a6a84d106a Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 21 Apr 2019 17:38:04 +0800 Subject: [PATCH] fixed a bug of window --- .../HandyControl_Shared/Controls/Window/Window.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Window/Window.cs b/src/Shared/HandyControl_Shared/Controls/Window/Window.cs index be713cfb..4da6e868 100644 --- a/src/Shared/HandyControl_Shared/Controls/Window/Window.cs +++ b/src/Shared/HandyControl_Shared/Controls/Window/Window.cs @@ -64,7 +64,7 @@ namespace HandyControl.Controls public static readonly DependencyProperty NonClientAreaHeightProperty = DependencyProperty.Register( "NonClientAreaHeight", typeof(double), typeof(Window), - new PropertyMetadata(28.0)); + new PropertyMetadata(26.0)); public static readonly DependencyProperty ShowNonClientAreaProperty = DependencyProperty.Register( "ShowNonClientArea", typeof(bool), typeof(Window), @@ -288,19 +288,25 @@ namespace HandyControl.Controls if (WindowState == WindowState.Maximized) { BorderThickness = new Thickness(); + _tempNonClientAreaHeight = NonClientAreaHeight; + NonClientAreaHeight += 8; } else if (WindowState == WindowState.Normal) { BorderThickness = _actualBorderThickness; + NonClientAreaHeight = _tempNonClientAreaHeight; } } protected void OnLoaded(RoutedEventArgs args) { _actualBorderThickness = BorderThickness; + _tempNonClientAreaHeight = NonClientAreaHeight; + if (WindowState == WindowState.Maximized) { BorderThickness = new Thickness(); + _tempNonClientAreaHeight += 8; } CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, @@ -312,7 +318,6 @@ namespace HandyControl.Controls CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (s, e) => Close())); CommandBindings.Add(new CommandBinding(SystemCommands.ShowSystemMenuCommand, ShowSystemMenu)); - _tempNonClientAreaHeight = NonClientAreaHeight; _tempWindowState = WindowState; _tempWindowStyle = WindowStyle; _tempResizeMode = ResizeMode; @@ -320,6 +325,11 @@ namespace HandyControl.Controls SwitchIsFullScreen(_isFullScreen); SwitchShowNonClientArea(_showNonClientArea); + if (WindowState == WindowState.Maximized) + { + _tempNonClientAreaHeight -= 8; + } + if (SizeToContent != SizeToContent.WidthAndHeight) return;