Skip to content

Commit

Permalink
Clamp progressbar indicator width and height to never drop below zero…
Browse files Browse the repository at this point in the history
… when calculating size.

Fixes AvaloniaUI#17393
  • Loading branch information
KieranDevvs committed Dec 22, 2024
1 parent 6b812c8 commit 1f09e4a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Avalonia.Controls/ProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,17 @@ private void UpdateIndicator()
// 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;
}
}
Expand Down

0 comments on commit 1f09e4a

Please sign in to comment.