System.Windows.Controls.InteractionHelper.UpdateVisualStateBase C# (CSharp) Method

UpdateVisualStateBase() public method

Update the visual state of the control.
public UpdateVisualStateBase ( bool useTransitions ) : void
useTransitions bool /// A value indicating whether to automatically generate transitions to /// the new state, or instantly transition to the new state. ///
return void
        public void UpdateVisualStateBase(bool useTransitions)
        {
            // Handle the Common states
            if(!Control.IsEnabled)
            {
                VisualStates.GoToState(Control, useTransitions, VisualStates.StateDisabled, VisualStates.StateNormal);
            }
            else if(IsReadOnly)
            {
                VisualStates.GoToState(Control, useTransitions, VisualStates.StateReadOnly, VisualStates.StateNormal);
            }
            else if(IsPressed)
            {
                VisualStates.GoToState(Control, useTransitions, VisualStates.StatePressed, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else if(IsMouseOver)
            {
                VisualStates.GoToState(Control, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(Control, useTransitions, VisualStates.StateNormal);
            }

            // Handle the Focused states
            if(IsFocused)
            {
                VisualStates.GoToState(Control, useTransitions, VisualStates.StateFocused, VisualStates.StateUnfocused);
            }
            else
            {
                VisualStates.GoToState(Control, useTransitions, VisualStates.StateUnfocused);
            }
        }
        #endregion UpdateVisualState

Usage Example

Example #1
0
 /// <summary>
 /// This method is invoked when the mouse enters the rating item.
 /// </summary>
 /// <param name="e">Information about the event.</param>
 protected override void OnMouseEnter(MouseEventArgs e)
 {
     if (_interactionHelper.AllowMouseEnter(e))
     {
         _interactionHelper.UpdateVisualStateBase(true);
     }
     base.OnMouseEnter(e);
 }
All Usage Examples Of System.Windows.Controls.InteractionHelper::UpdateVisualStateBase