/// <summary> /// Handles changes to the Value property. /// </summary> private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { d.CoerceValue(MinimumProperty); d.CoerceValue(MaximumProperty); StarControl starControl = (StarControl)d; if (starControl.Value == 0.0m) { starControl.starForeground.Fill = Brushes.Gray; } else { starControl.starForeground.Fill = starControl.StarForegroundColor; } Int32 marginLeftOffset = (Int32)(starControl.Value * (Decimal)STAR_SIZE); starControl.mask.Margin = new Thickness(marginLeftOffset, 0, 0, 0); starControl.InvalidateArrange(); starControl.InvalidateMeasure(); starControl.InvalidateVisual(); }