/// <summary>
 /// Handles changes to the BackgroundColor property.
 /// </summary>
 private static void OnBackgroundColorChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     StaticRating control = (StaticRating)d;
     foreach (Star star in control.spStars.Children)
         star.BackgroundColor = (SolidColorBrush)e.NewValue;
 }
        /// <summary>
        /// Sets up stars when Value or NumberOfStars properties change
        /// Will only show up to the number of stars requested (up to Maximum)
        /// so if Value > NumberOfStars * 1, then Value is clipped to maximum
        /// number of full stars
        /// </summary>
        /// <param name="ratingsControl"></param>
        private static void SetupStars(StaticRating ratingsControl)
        {
            double localValue = ratingsControl.Value;

            ratingsControl.spStars.Children.Clear();
            for (int i = 0; i < ratingsControl.NumberOfStars; i++)
            {
                Star star = new Star();
                star.BackgroundColor = ratingsControl.BackgroundColor;
                star.StarForegroundColor = ratingsControl.StarForegroundColor;
                star.StarOutlineColor = ratingsControl.StarOutlineColor;
                star.StarScaleWidth = ratingsControl.StarScaleWidth;
                star.StarScaleHeight = ratingsControl.StarScaleHeight;
                star.StarSize = ratingsControl.StarSize;

                if (localValue > 1)
                    star.Value = 1.0;
                else if (localValue > 0)
                {
                    star.Value = localValue;
                }
                else
                {
                    star.Value = 0.0;
                }

                localValue -= 1.0;
                ratingsControl.spStars.Children.Insert(i, star);
            }
        }
 /// <summary>
 /// Handles changes to the Value property.
 /// </summary>
 private static void OnStarScaleHeightChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     StaticRating ratingsControl = (StaticRating)d;
     foreach (Star star in ratingsControl.spStars.Children)
         star.StarScaleHeight = ratingsControl.StarScaleHeight;
 }
 /// <summary>
 /// Handles changes to the NumberOfStars property.
 /// </summary>
 private static void OnNumberOfStarsChanged(DependencyObject d,
     DependencyPropertyChangedEventArgs e)
 {
     StaticRating ratingsControl = (StaticRating)d;
     SetupStars(ratingsControl);
 }