Browse Source

Clamp progressbar indicator width and height to never drop below zero when calculating size. (#17816)

Fixes #17393
release/11.2.4
Kieran Devlin 1 year ago
committed by Max Katz
parent
commit
380c158edc
  1. 8
      src/Avalonia.Controls/ProgressBar.cs

8
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;
}
}

Loading…
Cancel
Save