diff --git a/src/Avalonia.Controls/ProgressBar.cs b/src/Avalonia.Controls/ProgressBar.cs index 220931b4f4..89ca28f5cc 100644 --- a/src/Avalonia.Controls/ProgressBar.cs +++ b/src/Avalonia.Controls/ProgressBar.cs @@ -378,17 +378,17 @@ namespace Avalonia.Controls // Indicator size calculation should consider the ProgressBar's Padding property setting if (Orientation == Orientation.Horizontal) { - _indicator.Width = (barSize.Width - _indicator.Margin.Left - _indicator.Margin.Right) * percent; + var width = (barSize.Width - _indicator.Margin.Left - _indicator.Margin.Right) * percent; + _indicator.Width = width > 0 ? width : 0; _indicator.Height = double.NaN; } else { _indicator.Width = double.NaN; - _indicator.Height = (barSize.Height - _indicator.Margin.Top - _indicator.Margin.Bottom) * - percent; + var height = (barSize.Height - _indicator.Margin.Top - _indicator.Margin.Bottom) * percent; + _indicator.Height = height > 0 ? height : 0; } - Percentage = percent * 100; } }