From 28f11181ba9bad9d4652f7e4586a070df31537d3 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Thu, 13 Dec 2018 13:39:44 +0800 Subject: [PATCH] add more styles of groupbox --- HandyControl/Controls/Attach/InfoElement.cs | 32 +--- HandyControl/Controls/Attach/TitleElement.cs | 32 ++++ .../Themes/Styles/Base/GroupBoxBaseStyle.xaml | 146 +++++++++++++++--- HandyControl/Themes/Styles/GroupBox.xaml | 44 +----- .../UserControl/Main/LeftMainContent.xaml | 10 +- .../UserControl/Styles/GroupBoxDemoCtl.xaml | 31 +++- 6 files changed, 195 insertions(+), 100 deletions(-) diff --git a/HandyControl/Controls/Attach/InfoElement.cs b/HandyControl/Controls/Attach/InfoElement.cs index 73777651..654baae1 100644 --- a/HandyControl/Controls/Attach/InfoElement.cs +++ b/HandyControl/Controls/Attach/InfoElement.cs @@ -3,18 +3,8 @@ using HandyControl.Data; namespace HandyControl.Controls { - public class InfoElement + public class InfoElement : TitleElement { - /// - /// 标题 - /// - public static readonly DependencyProperty TitleProperty = DependencyProperty.RegisterAttached( - "Title", typeof(string), typeof(InfoElement), new PropertyMetadata(default(string))); - - public static void SetTitle(DependencyObject element, string value) => element.SetValue(TitleProperty, value); - - public static string GetTitle(DependencyObject element) => (string) element.GetValue(TitleProperty); - /// /// 占位符 /// @@ -45,26 +35,6 @@ namespace HandyControl.Controls public static string GetSymbol(DependencyObject element) => (string)element.GetValue(SymbolProperty); - /// - /// 标题对齐方式 - /// - public static readonly DependencyProperty TitleAlignmentProperty = DependencyProperty.RegisterAttached( - "TitleAlignment", typeof(TitleAlignment), typeof(InfoElement), new FrameworkPropertyMetadata(TitleAlignment.Top, FrameworkPropertyMetadataOptions.Inherits)); - - public static void SetTitleAlignment(DependencyObject element, TitleAlignment value) => element.SetValue(TitleAlignmentProperty, value); - - public static TitleAlignment GetTitleAlignment(DependencyObject element) => (TitleAlignment) element.GetValue(TitleAlignmentProperty); - - /// - /// 标题宽度 - /// - public static readonly DependencyProperty TitleWidthProperty = DependencyProperty.RegisterAttached( - "TitleWidth", typeof(GridLength), typeof(InfoElement), new FrameworkPropertyMetadata(new GridLength(120.0), FrameworkPropertyMetadataOptions.Inherits)); - - public static void SetTitleWidth(DependencyObject element, GridLength value) => element.SetValue(TitleWidthProperty, value); - - public static GridLength GetTitleWidth(DependencyObject element) => (GridLength)element.GetValue(TitleWidthProperty); - /// /// 内容高度 /// diff --git a/HandyControl/Controls/Attach/TitleElement.cs b/HandyControl/Controls/Attach/TitleElement.cs index 14415c6f..f185f98f 100644 --- a/HandyControl/Controls/Attach/TitleElement.cs +++ b/HandyControl/Controls/Attach/TitleElement.cs @@ -1,10 +1,20 @@ using System.Windows; using System.Windows.Media; +using HandyControl.Data; namespace HandyControl.Controls { public class TitleElement { + public static readonly DependencyProperty TitleProperty = DependencyProperty.RegisterAttached( + "Title", typeof(string), typeof(TitleElement), new PropertyMetadata(default(string))); + + public static void SetTitle(DependencyObject element, string value) + => element.SetValue(TitleProperty, value); + + public static string GetTitle(DependencyObject element) + => (string) element.GetValue(TitleProperty); + public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached( "Background", typeof(Brush), typeof(TitleElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits)); @@ -31,5 +41,27 @@ namespace HandyControl.Controls public static Brush GetBorderBrush(DependencyObject element) => (Brush) element.GetValue(BorderBrushProperty); + + /// + /// 标题对齐方式 + /// + public static readonly DependencyProperty TitleAlignmentProperty = DependencyProperty.RegisterAttached( + "TitleAlignment", typeof(TitleAlignment), typeof(TitleElement), new FrameworkPropertyMetadata(TitleAlignment.Top, FrameworkPropertyMetadataOptions.Inherits)); + + public static void SetTitleAlignment(DependencyObject element, TitleAlignment value) + => element.SetValue(TitleAlignmentProperty, value); + + public static TitleAlignment GetTitleAlignment(DependencyObject element) + => (TitleAlignment) element.GetValue(TitleAlignmentProperty); + + /// + /// 标题宽度 + /// + public static readonly DependencyProperty TitleWidthProperty = DependencyProperty.RegisterAttached( + "TitleWidth", typeof(GridLength), typeof(TitleElement), new FrameworkPropertyMetadata(new GridLength(120.0), FrameworkPropertyMetadataOptions.Inherits)); + + public static void SetTitleWidth(DependencyObject element, GridLength value) => element.SetValue(TitleWidthProperty, value); + + public static GridLength GetTitleWidth(DependencyObject element) => (GridLength)element.GetValue(TitleWidthProperty); } } \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Base/GroupBoxBaseStyle.xaml b/HandyControl/Themes/Styles/Base/GroupBoxBaseStyle.xaml index 69d1f5fa..839b57bc 100644 --- a/HandyControl/Themes/Styles/Base/GroupBoxBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/GroupBoxBaseStyle.xaml @@ -2,34 +2,144 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:HandyControl.Controls"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/GroupBox.xaml b/HandyControl/Themes/Styles/GroupBox.xaml index eda414ae..86ee6b9b 100644 --- a/HandyControl/Themes/Styles/GroupBox.xaml +++ b/HandyControl/Themes/Styles/GroupBox.xaml @@ -1,6 +1,5 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> @@ -8,45 +7,8 @@ + +