diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml
index ac5613e2..5c273b76 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml
@@ -1,8 +1,15 @@
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Controls/Grid/Col.cs b/src/Shared/HandyControl_Shared/Controls/Grid/Col.cs
index 1a77bc96..62c8f908 100644
--- a/src/Shared/HandyControl_Shared/Controls/Grid/Col.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Grid/Col.cs
@@ -1,4 +1,5 @@
-using System.Windows;
+using System;
+using System.Windows;
using System.Windows.Controls;
using HandyControl.Data;
using HandyControl.Tools.Extension;
@@ -66,6 +67,10 @@ namespace HandyControl.Controls
case ColLayoutStatus.Xxl:
result = Layout.Xxl;
break;
+ case ColLayoutStatus.Auto:
+ break;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(status), status, null);
}
}
else
diff --git a/src/Shared/HandyControl_Shared/Controls/Grid/Row.cs b/src/Shared/HandyControl_Shared/Controls/Grid/Row.cs
index e659178d..36670f02 100644
--- a/src/Shared/HandyControl_Shared/Controls/Grid/Row.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Grid/Row.cs
@@ -13,6 +13,8 @@ namespace HandyControl.Controls
private double _maxChildDesiredHeight;
+ private double _totalAutoWidth;
+
public static readonly DependencyProperty GutterProperty = DependencyProperty.Register(
"Gutter", typeof(double), typeof(Row), new PropertyMetadata(ValueBoxes.Double0Box, null, OnGutterCoerce), ValidateHelper.IsInRangeOfPosDoubleIncludeZero);
@@ -29,6 +31,7 @@ namespace HandyControl.Controls
var totalCellCount = 0;
var totalRowCount = 1;
var gutterHalf = Gutter / 2;
+ _totalAutoWidth = 0;
foreach (var child in InternalChildren.OfType
())
{
@@ -40,12 +43,7 @@ namespace HandyControl.Controls
{
_maxChildDesiredHeight = childDesiredSize.Height;
}
- }
- _layoutStatus = ColLayout.GetLayoutStatus(constraint.Width);
-
- foreach (var child in InternalChildren.OfType())
- {
var cellCount = child.GetLayoutCellCount(_layoutStatus);
totalCellCount += cellCount;
@@ -54,16 +52,21 @@ namespace HandyControl.Controls
totalCellCount = cellCount;
totalRowCount++;
}
+
+ if (cellCount == 0)
+ {
+ _totalAutoWidth += childDesiredSize.Width;
+ }
}
- return new Size(0, _maxChildDesiredHeight * totalRowCount - Gutter);
+ return new Size(constraint.Width, _maxChildDesiredHeight * totalRowCount - Gutter);
}
protected override Size ArrangeOverride(Size finalSize)
{
var totalCellCount = 0;
var gutterHalf = Gutter / 2;
- var itemWidth = (finalSize.Width + Gutter) / ColLayout.ColMaxCellCount;
+ var itemWidth = (finalSize.Width - _totalAutoWidth + Gutter) / ColLayout.ColMaxCellCount;
var childBounds = new Rect(-gutterHalf, -gutterHalf, 0, _maxChildDesiredHeight);
_layoutStatus = ColLayout.GetLayoutStatus(finalSize.Width);
@@ -72,7 +75,8 @@ namespace HandyControl.Controls
var cellCount = child.GetLayoutCellCount(_layoutStatus);
totalCellCount += cellCount;
- var childWidth = cellCount * itemWidth;
+ var childWidth = cellCount > 0 ? cellCount * itemWidth : child.DesiredSize.Width;
+
childBounds.Width = childWidth;
childBounds.X += child.Offset * itemWidth;
if (totalCellCount > ColLayout.ColMaxCellCount)
diff --git a/src/Shared/HandyControl_Shared/Controls/Other/Divider.cs b/src/Shared/HandyControl_Shared/Controls/Other/Divider.cs
index 87ab5736..5d15f7d1 100644
--- a/src/Shared/HandyControl_Shared/Controls/Other/Divider.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Other/Divider.cs
@@ -1,5 +1,6 @@
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Media;
using HandyControl.Data;
namespace HandyControl.Controls
@@ -11,19 +12,10 @@ namespace HandyControl.Controls
public object Content
{
- get => (object) GetValue(ContentProperty);
+ get => GetValue(ContentProperty);
set => SetValue(ContentProperty, value);
}
- public static readonly DependencyProperty DashedProperty = DependencyProperty.Register(
- "Dashed", typeof(bool), typeof(Divider), new PropertyMetadata(ValueBoxes.FalseBox));
-
- public bool Dashed
- {
- get => (bool) GetValue(DashedProperty);
- set => SetValue(DashedProperty, value);
- }
-
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
"Orientation", typeof(Orientation), typeof(Divider), new PropertyMetadata(default(Orientation)));
@@ -32,5 +24,59 @@ namespace HandyControl.Controls
get => (Orientation) GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}
+
+ public static readonly DependencyProperty ContentTemplateProperty = DependencyProperty.Register(
+ "ContentTemplate", typeof(DataTemplate), typeof(Divider), new PropertyMetadata(default(DataTemplate)));
+
+ public DataTemplate ContentTemplate
+ {
+ get => (DataTemplate) GetValue(ContentTemplateProperty);
+ set => SetValue(ContentTemplateProperty, value);
+ }
+
+ public static readonly DependencyProperty ContentStringFormatProperty = DependencyProperty.Register(
+ "ContentStringFormat", typeof(string), typeof(Divider), new PropertyMetadata(default(string)));
+
+ public string ContentStringFormat
+ {
+ get => (string) GetValue(ContentStringFormatProperty);
+ set => SetValue(ContentStringFormatProperty, value);
+ }
+
+ public static readonly DependencyProperty ContentTemplateSelectorProperty = DependencyProperty.Register(
+ "ContentTemplateSelector", typeof(DataTemplateSelector), typeof(Divider), new PropertyMetadata(default(DataTemplateSelector)));
+
+ public DataTemplateSelector ContentTemplateSelector
+ {
+ get => (DataTemplateSelector) GetValue(ContentTemplateSelectorProperty);
+ set => SetValue(ContentTemplateSelectorProperty, value);
+ }
+
+ public static readonly DependencyProperty LineStrokeProperty = DependencyProperty.Register(
+ "LineStroke", typeof(Brush), typeof(Divider), new PropertyMetadata(default(Brush)));
+
+ public Brush LineStroke
+ {
+ get => (Brush) GetValue(LineStrokeProperty);
+ set => SetValue(LineStrokeProperty, value);
+ }
+
+ public static readonly DependencyProperty LineStrokeThicknessProperty = DependencyProperty.Register(
+ "LineStrokeThickness", typeof(double), typeof(Divider), new PropertyMetadata(ValueBoxes.Double1Box));
+
+ public double LineStrokeThickness
+ {
+ get => (double) GetValue(LineStrokeThicknessProperty);
+ set => SetValue(LineStrokeThicknessProperty, value);
+ }
+
+ public static readonly DependencyProperty LineStrokeDashArrayProperty = DependencyProperty.Register(
+ "LineStrokeDashArray", typeof(DoubleCollection), typeof(Divider), new PropertyMetadata(new DoubleCollection()));
+
+ public DoubleCollection LineStrokeDashArray
+ {
+ get => (DoubleCollection) GetValue(LineStrokeDashArrayProperty);
+ set => SetValue(LineStrokeDashArrayProperty, value);
+ }
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Data/Enum/ColLayoutStatus.cs b/src/Shared/HandyControl_Shared/Data/Enum/ColLayoutStatus.cs
index 5deda29f..bf0a6ea9 100644
--- a/src/Shared/HandyControl_Shared/Data/Enum/ColLayoutStatus.cs
+++ b/src/Shared/HandyControl_Shared/Data/Enum/ColLayoutStatus.cs
@@ -8,5 +8,6 @@
Lg,
Xl,
Xxl,
+ Auto
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/DividerBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/DividerBaseStyle.xaml
index cb3723f0..1156a56d 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/DividerBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/DividerBaseStyle.xaml
@@ -4,6 +4,32 @@
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs b/src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs
index 91785099..4db36da3 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs
@@ -13,6 +13,8 @@ namespace HandyControl.Tools.Extension
{
public static readonly int ColMaxCellCount = 24;
+ public static readonly int HalfColMaxCellCount = 12;
+
public static readonly int XsMaxWidth = 768;
public static readonly int SmMaxWidth = 992;