diff --git a/HandyControl/Controls/Badge/Badge.cs b/HandyControl/Controls/Badge/Badge.cs index 3b3cc918..23faa7f4 100644 --- a/HandyControl/Controls/Badge/Badge.cs +++ b/HandyControl/Controls/Badge/Badge.cs @@ -6,11 +6,6 @@ namespace HandyControl.Controls { public class Badge : ContentControl { - public Badge() - { - - } - public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string), typeof(Badge), new PropertyMetadata(default(string))); diff --git a/HandyControl/Controls/Panel/SimplePanel.cs b/HandyControl/Controls/Panel/SimplePanel.cs new file mode 100644 index 00000000..41e9c532 --- /dev/null +++ b/HandyControl/Controls/Panel/SimplePanel.cs @@ -0,0 +1,38 @@ +using System; +using System.Windows; +using System.Windows.Controls; + +namespace HandyControl.Controls +{ + public class SimplePanel : Panel + { + protected override Size MeasureOverride(Size availableSize) + { + var maxSize = new Size(); + var children = InternalChildren; + + for (int i = 0, count = children.Count; i < count; ++i) + { + var child = children[i]; + if (child != null) + { + child.Measure(availableSize); + maxSize.Width = Math.Max(maxSize.Width, child.DesiredSize.Width); + maxSize.Height = Math.Max(maxSize.Height, child.DesiredSize.Height); + } + } + + return maxSize; + } + + protected override Size ArrangeOverride(Size arrangeSize) + { + foreach (UIElement child in InternalChildren) + { + child?.Arrange(new Rect(arrangeSize)); + } + + return arrangeSize; + } + } +} \ No newline at end of file diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj index a56db0e9..da2a09d7 100644 --- a/HandyControl/HandyControl.csproj +++ b/HandyControl/HandyControl.csproj @@ -116,6 +116,7 @@ + diff --git a/HandyControl/Themes/Styles/Base/BadgeBaseStyle.xaml b/HandyControl/Themes/Styles/Base/BadgeBaseStyle.xaml index 811df7bf..f17adcc1 100644 --- a/HandyControl/Themes/Styles/Base/BadgeBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/BadgeBaseStyle.xaml @@ -15,12 +15,12 @@ - + - + - + diff --git a/HandyControlDemo/UserControl/Controls/BadgeDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/BadgeDemoCtl.xaml index e341b740..f030241c 100644 --- a/HandyControlDemo/UserControl/Controls/BadgeDemoCtl.xaml +++ b/HandyControlDemo/UserControl/Controls/BadgeDemoCtl.xaml @@ -5,10 +5,10 @@ xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs" Background="{DynamicResource RegionBrush}"> - +