From 1784b5178124cee838de330c9cbbfd9875861629 Mon Sep 17 00:00:00 2001 From: ahopper Date: Mon, 5 Mar 2018 10:55:06 +0000 Subject: [PATCH] ProgressBar MinWidth & MinHeight set in template --- src/Avalonia.Controls/ProgressBar.cs | 26 +-------- src/Avalonia.Themes.Default/ProgressBar.xaml | 58 +++++++++++++------- 2 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/Avalonia.Controls/ProgressBar.cs b/src/Avalonia.Controls/ProgressBar.cs index 19744d3038..34954dd0d5 100644 --- a/src/Avalonia.Controls/ProgressBar.cs +++ b/src/Avalonia.Controls/ProgressBar.cs @@ -26,12 +26,13 @@ namespace Avalonia.Controls static ProgressBar() { + PseudoClass(OrientationProperty, o => o == Avalonia.Controls.Orientation.Vertical, ":vertical"); + PseudoClass(OrientationProperty, o => o == Avalonia.Controls.Orientation.Horizontal, ":horizontal"); + ValueProperty.Changed.AddClassHandler(x => x.ValueChanged); IsIndeterminateProperty.Changed.AddClassHandler( (p, e) => { if (p._indicator != null) p.UpdateIsIndeterminate((bool)e.NewValue); }); - OrientationProperty.Changed.AddClassHandler( - (p, e) => { if (p._indicator != null) p.UpdateOrientation((Orientation)e.NewValue); }); } public bool IsIndeterminate @@ -59,7 +60,6 @@ namespace Avalonia.Controls _indicator = e.NameScope.Get("PART_Indicator"); UpdateIndicator(Bounds.Size); - UpdateOrientation(Orientation); UpdateIsIndeterminate(IsIndeterminate); } @@ -86,26 +86,6 @@ namespace Avalonia.Controls } } - private void UpdateOrientation(Orientation orientation) - { - if (orientation == Orientation.Horizontal) - { - MinHeight = Math.Min(14, double.IsNaN(Height) ? double.MaxValue : Height); - MinWidth = Math.Min(200, double.IsNaN(Width) ? double.MaxValue : Width); - - _indicator.HorizontalAlignment = HorizontalAlignment.Left; - _indicator.VerticalAlignment = VerticalAlignment.Stretch; - } - else - { - MinHeight = Math.Min(200, double.IsNaN(Height) ? double.MaxValue : Height); - MinWidth = Math.Min(14, double.IsNaN(Width) ? double.MaxValue : Width); - - _indicator.HorizontalAlignment = HorizontalAlignment.Stretch; - _indicator.VerticalAlignment = VerticalAlignment.Bottom; - } - } - private void UpdateIsIndeterminate(bool isIndeterminate) { if (isIndeterminate) diff --git a/src/Avalonia.Themes.Default/ProgressBar.xaml b/src/Avalonia.Themes.Default/ProgressBar.xaml index 82f385e16b..c9c898562c 100644 --- a/src/Avalonia.Themes.Default/ProgressBar.xaml +++ b/src/Avalonia.Themes.Default/ProgressBar.xaml @@ -1,20 +1,38 @@ - \ No newline at end of file + + + + + + + \ No newline at end of file