Skip to content

Commit 07f3ad2

Browse files
authored
Clamp progressbar indicator width and height to never drop below zero when calculating size. (AvaloniaUI#17816)
Fixes AvaloniaUI#17393
1 parent 6b812c8 commit 07f3ad2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Avalonia.Controls/ProgressBar.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -378,17 +378,17 @@ private void UpdateIndicator()
378378
// Indicator size calculation should consider the ProgressBar's Padding property setting
379379
if (Orientation == Orientation.Horizontal)
380380
{
381-
_indicator.Width = (barSize.Width - _indicator.Margin.Left - _indicator.Margin.Right) * percent;
381+
var width = (barSize.Width - _indicator.Margin.Left - _indicator.Margin.Right) * percent;
382+
_indicator.Width = width > 0 ? width : 0;
382383
_indicator.Height = double.NaN;
383384
}
384385
else
385386
{
386387
_indicator.Width = double.NaN;
387-
_indicator.Height = (barSize.Height - _indicator.Margin.Top - _indicator.Margin.Bottom) *
388-
percent;
388+
var height = (barSize.Height - _indicator.Margin.Top - _indicator.Margin.Bottom) * percent;
389+
_indicator.Height = height > 0 ? height : 0;
389390
}
390391

391-
392392
Percentage = percent * 100;
393393
}
394394
}

0 commit comments

Comments
 (0)