From c4a68fc0130af5dda8210cc8e408fbeabe38c078 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Tue, 18 Sep 2018 13:49:11 +0800 Subject: [PATCH] 1. Fixed a bug of WindowBorderless, when the SizeToContent property is set to a value, a black area will be display; 2. Some styles have been modified, including button, menu and popupwindow --- HandyControl/Controls/Window/PopupWindow.xaml | 28 ++++++++++--------- .../Controls/Window/PopupWindow.xaml.cs | 9 +----- .../Controls/Window/WindowBorderless.cs | 11 ++++++++ HandyControl/Properties/AssemblyInfo.cs | 4 +-- .../Styles/Base/ButtonBaseBaseStyle.xaml | 2 ++ .../Styles/Base/ContextMenuBaseStyle.xaml | 19 +++++++++---- HandyControlDemo/Properties/AssemblyInfo.cs | 4 +-- 7 files changed, 46 insertions(+), 31 deletions(-) diff --git a/HandyControl/Controls/Window/PopupWindow.xaml b/HandyControl/Controls/Window/PopupWindow.xaml index 0aaca2f7..5d1d6f54 100644 --- a/HandyControl/Controls/Window/PopupWindow.xaml +++ b/HandyControl/Controls/Window/PopupWindow.xaml @@ -1,12 +1,14 @@  @@ -31,25 +33,25 @@ - + - - - - - diff --git a/HandyControl/Controls/Window/PopupWindow.xaml.cs b/HandyControl/Controls/Window/PopupWindow.xaml.cs index a6e022af..baf4a9e3 100644 --- a/HandyControl/Controls/Window/PopupWindow.xaml.cs +++ b/HandyControl/Controls/Window/PopupWindow.xaml.cs @@ -45,14 +45,7 @@ namespace HandyControl.Controls public UIElement Child { get => MainBorder.Child; - set - { - MainBorder.Child = value; - if (value is FrameworkElement temp) - { - TitleBlock.Width = temp.Width - 40; - } - } + set => MainBorder.Child = value; } public bool ShowTitle diff --git a/HandyControl/Controls/Window/WindowBorderless.cs b/HandyControl/Controls/Window/WindowBorderless.cs index 0c2b9484..98b456a1 100644 --- a/HandyControl/Controls/Window/WindowBorderless.cs +++ b/HandyControl/Controls/Window/WindowBorderless.cs @@ -120,6 +120,17 @@ namespace HandyControl.Controls } } + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (SizeToContent != SizeToContent.WidthAndHeight) + return; + + SizeToContent = SizeToContent.Height; + Dispatcher.BeginInvoke(new Action(() => { SizeToContent = SizeToContent.WidthAndHeight; })); + } + public Brush CloseButtonForeground { get => (Brush)GetValue(CloseButtonForegroundProperty); diff --git a/HandyControl/Properties/AssemblyInfo.cs b/HandyControl/Properties/AssemblyInfo.cs index ac6957d3..abaf7381 100644 --- a/HandyControl/Properties/AssemblyInfo.cs +++ b/HandyControl/Properties/AssemblyInfo.cs @@ -10,5 +10,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] -[assembly: AssemblyVersion("1.2.1.1")] -[assembly: AssemblyFileVersion("1.2.1.1")] +[assembly: AssemblyVersion("1.2.1.2")] +[assembly: AssemblyFileVersion("1.2.1.2")] diff --git a/HandyControl/Themes/Styles/Base/ButtonBaseBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ButtonBaseBaseStyle.xaml index d0fc1a9b..b3d31de3 100644 --- a/HandyControl/Themes/Styles/Base/ButtonBaseBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/ButtonBaseBaseStyle.xaml @@ -16,6 +16,8 @@ + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Base/ContextMenuBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ContextMenuBaseStyle.xaml index 2e485e57..db073d71 100644 --- a/HandyControl/Themes/Styles/Base/ContextMenuBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/ContextMenuBaseStyle.xaml @@ -2,6 +2,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:HandyControl.Controls"> + + + +