From b1a133ce80add68d7788e7fb170e5aaecc5e1797 Mon Sep 17 00:00:00 2001 From: GF-Huang Date: Fri, 24 May 2024 10:44:43 +0800 Subject: [PATCH] Add `ItemMinWidth` and `TopLevelMinWidth` for `MenuAttach`. --- .../UserControl/Styles/MenuDemoCtl.xaml | 130 +++++++++++++----- .../Controls/Attach/MenuAttach.cs | 14 ++ .../HandyControl_Shared/Data/ValueBoxes.cs | 4 + .../Themes/Styles/Base/MenuBaseStyle.xaml | 6 +- 4 files changed, 117 insertions(+), 37 deletions(-) diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Styles/MenuDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Styles/MenuDemoCtl.xaml index 6b4a12371..305ef751b 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Styles/MenuDemoCtl.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Styles/MenuDemoCtl.xaml @@ -6,39 +6,101 @@ xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension" Background="{DynamicResource RegionBrush}"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/MenuAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/MenuAttach.cs index eae15ccaf..880986fe2 100644 --- a/src/Shared/HandyControl_Shared/Controls/Attach/MenuAttach.cs +++ b/src/Shared/HandyControl_Shared/Controls/Attach/MenuAttach.cs @@ -31,4 +31,18 @@ public static void SetItemPadding(DependencyObject element, Thickness value) public static Thickness GetItemPadding(DependencyObject element) => (Thickness) element.GetValue(ItemPaddingProperty); + + public static readonly DependencyProperty ItemMinWidthProperty = DependencyProperty.RegisterAttached( + "ItemMinWidth", typeof(double), typeof(MenuAttach), new PropertyMetadata(ValueBoxes.Double240Box)); + + public static void SetItemMinWidth(DependencyObject obj, double value) => obj.SetValue(ItemMinWidthProperty, value); + + public static double GetItemMinWidth(DependencyObject obj) => (double) obj.GetValue(ItemMinWidthProperty); + + public static readonly DependencyProperty TopLevelMinWidthProperty = DependencyProperty.RegisterAttached( + "TopLevelMinWidth", typeof(double), typeof(MenuAttach), new PropertyMetadata(ValueBoxes.Double44Box)); + + public static void SetTopLevelMinWidth(DependencyObject obj, double value) => obj.SetValue(TopLevelMinWidthProperty, value); + + public static double GetTopLevelMinWidth(DependencyObject obj) => (double) obj.GetValue(TopLevelMinWidthProperty); } diff --git a/src/Shared/HandyControl_Shared/Data/ValueBoxes.cs b/src/Shared/HandyControl_Shared/Data/ValueBoxes.cs index 28f747c2a..c41f00651 100644 --- a/src/Shared/HandyControl_Shared/Data/ValueBoxes.cs +++ b/src/Shared/HandyControl_Shared/Data/ValueBoxes.cs @@ -33,10 +33,14 @@ internal static class ValueBoxes internal static object Double20Box = 20.0; + internal static object Double44Box = 44.0; + internal static object Double100Box = 100.0; internal static object Double200Box = 200.0; + internal static object Double240Box = 240.0; + internal static object Double300Box = 300.0; internal static object DoubleNeg1Box = -1.0; diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml index d73cc7e14..b03b90653 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml @@ -15,7 +15,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -147,7 +147,7 @@ - +