/// <summary> /// DisplayValueProperty property changed handler. /// </summary> /// <param name="oldValue">The old value.</param> /// <param name="newValue">The new value.</param> private void OnDisplayValueChanged(double oldValue, double newValue) { if (!_settingDisplayValue) { _settingDisplayValue = true; DisplayValue = oldValue; throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture, $"Invalid attempt to change read-only property DisplayValue.")); } if (newValue <= 0.0) { VisualStates.GoToState(this, true, StateEmpty); } else if (newValue >= 1.0) { VisualStates.GoToState(this, true, StateFilled); } else { VisualStates.GoToState(this, true, StatePartial); } }
/// <summary> /// Updates the state of the visual. /// </summary> /// <param name="useTransitions">If set to <c>true</c> use transitions.</param> /// <remarks>The header will follow the parent accordionitem states.</remarks> internal virtual void UpdateVisualState(bool useTransitions) { // the visualstate of the header is completely dependent on the parent state. if (ParentAccordionItem == null) { return; } if (ParentAccordionItem.IsSelected) { VisualStates.GoToState(this, useTransitions, VisualStates.StateExpanded); } else { VisualStates.GoToState(this, useTransitions, VisualStates.StateCollapsed); } switch (ParentAccordionItem.ExpandDirection) { // no animations on an expanddirection change. case ExpandDirection.Down: VisualStates.GoToState(this, false, VisualStates.StateExpandDown); break; case ExpandDirection.Up: VisualStates.GoToState(this, false, VisualStates.StateExpandUp); break; case ExpandDirection.Left: VisualStates.GoToState(this, false, VisualStates.StateExpandLeft); break; default: VisualStates.GoToState(this, false, VisualStates.StateExpandRight); break; } }
/// <summary> /// Updates the hover states of the rating items. /// </summary> private void UpdateHoverStates() { if (HoveredRatingItem != null && !IsReadOnly) { IList <RatingItem> ratingItems = GetRatingItems().ToList(); int indexOfItem = ratingItems.IndexOf(HoveredRatingItem); double total = ratingItems.Count(); double filled = indexOfItem + 1; DisplayValue = filled / total; for (int cnt = 0; cnt < ratingItems.Count; cnt++) { RatingItem ratingItem = ratingItems[cnt]; if (cnt <= indexOfItem && SelectionMode == RatingSelectionMode.Continuous) { VisualStates.GoToState(ratingItem, true, VisualStates.StateMouseOver); } else { IUpdateVisualState updateVisualState = ratingItem; updateVisualState.UpdateVisualState(true); } } } else { DisplayValue = Value.GetValueOrDefault(); foreach (IUpdateVisualState updateVisualState in GetRatingItems().OfType <IUpdateVisualState>()) { updateVisualState.UpdateVisualState(true); } } }