Browse Source

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

Fixes #17393
pull/16805/head
Kieran Devlin 1 year ago
committed by GitHub
parent
commit
07f3ad23e4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  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