Browse Source

Merge pull request #62 from ncarrillo/fix-progressbar

Fixed a bug in ProgressBar
pull/66/head
Steven Kirk 11 years ago
parent
commit
b3bdbe8025
  1. 11
      Perspex.Controls/ProgressBar.cs

11
Perspex.Controls/ProgressBar.cs

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

Loading…
Cancel
Save