diff --git a/Perspex.Controls/ProgressBar.cs b/Perspex.Controls/ProgressBar.cs index 232039b802..f14751a0e7 100644 --- a/Perspex.Controls/ProgressBar.cs +++ b/Perspex.Controls/ProgressBar.cs @@ -8,6 +8,7 @@ namespace Perspex.Controls { using Perspex.Controls.Primitives; using Perspex.Controls.Templates; + using System; /// /// A control used to indicate the progress of an operation. @@ -15,13 +16,15 @@ namespace Perspex.Controls public class ProgressBar : RangeBase { /// + /// + private Border indicator; protected override Size ArrangeOverride(Size finalSize) { var size = base.ArrangeOverride(finalSize); - var b = this.Bounds; - - var indicator = this.GetTemplateChild("PART_Indicator"); - indicator.Width = finalSize.Width * (this.Value / 100); + this.indicator = this.indicator ?? this.GetTemplateChild("PART_Indicator"); + + double percent = this.Maximum == this.Minimum ? 1.0 : (this.Value - this.Minimum) / (this.Maximum - this.Minimum); + indicator.Width = finalSize.Width * percent; return size; }