private static void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { RadRating rating = sender as RadRating; if (rating.settingValuePropertySilently) { return; } if (!rating.IsTemplateApplied) { return; } double oldValue = (double)args.OldValue; double newValue = RadMath.CoerceValue((double)args.NewValue, 0, rating.itemsSource.Count); if (newValue != rating.Value) { rating.SetValuePropertySilently(ValueProperty, newValue); } if (newValue != oldValue) { rating.HandleValueChange(oldValue, newValue); } }
private static void OnAutoGeneratedItemsCountChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { RadRating rating = sender as RadRating; if (!rating.IsTemplateApplied) { return; } if ((int)args.OldValue == 0 && rating.itemsSource.Count != 0) { throw new InvalidOperationException(AutoGeneratedItemsCountExceptionMessage); } rating.isItemsSourceChangedSilently = true; rating.itemsSource.Clear(); int newValue = (int)args.NewValue; if (newValue <= 0) { rating.AutoGeneratedItemsCount = 0; } else { rating.GenerateRatingItems(); double coercedValue = RadMath.CoerceValue(rating.Value, 0, rating.itemsSource.Count); if (rating.Value != coercedValue) { rating.SetValuePropertySilently(ValueProperty, coercedValue); rating.UpdateDisplayValue(); rating.UpdateFillRatio(); } } rating.isItemsSourceChangedSilently = false; rating.PopulateRatingPanel(); }