GoToState() public static method

Use VisualStateManager to change the visual state of the control.
public static GoToState ( Control control, bool useTransitions ) : void
control Control /// Control whose visual state is being changed. ///
useTransitions bool /// A value indicating whether to use transitions when updating the /// visual state, or to snap directly to the new visual state. ///
return void
Beispiel #1
0
 // Token: 0x060056BE RID: 22206 RVA: 0x0014E788 File Offset: 0x0014C988
 internal override void ChangeVisualState(bool useTransitions)
 {
     if (!base.IsEnabled)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Disabled",
             "Normal"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Normal", useTransitions);
     }
     base.ChangeVisualState(useTransitions);
 }
Beispiel #2
0
        //-------------------------------------------------------------------
        //
        //  Protected Methods
        //
        //-------------------------------------------------------------------

        #region Protected Methods

        internal override void ChangeVisualState(bool useTransitions)
        {
            // Change to the correct state in the Interaction group
            if (!IsEnabled)
            {
                // [copied from SL code]
                // If our child is a control then we depend on it displaying a proper "disabled" state.  If it is not a control
                // (ie TextBlock, Border, etc) then we will use our visuals to show a disabled state.
                VisualStateManager.GoToState(this, Content is Control ? VisualStates.StateNormal : VisualStates.StateDisabled, useTransitions);
            }
            else if (IsMouseOver)
            {
                VisualStateManager.GoToState(this, VisualStates.StateMouseOver, useTransitions);
            }
            else
            {
                VisualStateManager.GoToState(this, VisualStates.StateNormal, useTransitions);
            }

            // Change to the correct state in the Selection group
            if (IsSelected)
            {
                if (Selector.GetIsSelectionActive(this))
                {
                    VisualStateManager.GoToState(this, VisualStates.StateSelected, useTransitions);
                }
                else
                {
                    VisualStates.GoToState(this, useTransitions, VisualStates.StateSelectedUnfocused, VisualStates.StateSelected);
                }
            }
            else
            {
                VisualStateManager.GoToState(this, VisualStates.StateUnselected, useTransitions);
            }

            if (IsKeyboardFocused)
            {
                VisualStateManager.GoToState(this, VisualStates.StateFocused, useTransitions);
            }
            else
            {
                VisualStateManager.GoToState(this, VisualStates.StateUnfocused, useTransitions);
            }

            base.ChangeVisualState(useTransitions);
        }
Beispiel #3
0
 // Token: 0x0600515A RID: 20826 RVA: 0x0016CFB0 File Offset: 0x0016B1B0
 internal override void ChangeVisualState(bool useTransitions)
 {
     if (!base.IsEnabled)
     {
         VisualStateManager.GoToState(this, (base.Content is Control) ? "Normal" : "Disabled", useTransitions);
     }
     else if (base.IsMouseOver)
     {
         VisualStateManager.GoToState(this, "MouseOver", useTransitions);
     }
     else
     {
         VisualStateManager.GoToState(this, "Normal", useTransitions);
     }
     if (this.IsSelected)
     {
         if (Selector.GetIsSelectionActive(this))
         {
             VisualStateManager.GoToState(this, "Selected", useTransitions);
         }
         else
         {
             VisualStates.GoToState(this, useTransitions, new string[]
             {
                 "SelectedUnfocused",
                 "Selected"
             });
         }
     }
     else
     {
         VisualStateManager.GoToState(this, "Unselected", useTransitions);
     }
     if (base.IsKeyboardFocused)
     {
         VisualStateManager.GoToState(this, "Focused", useTransitions);
     }
     else
     {
         VisualStateManager.GoToState(this, "Unfocused", useTransitions);
     }
     base.ChangeVisualState(useTransitions);
 }
Beispiel #4
0
        /// <summary>
        /// Change to the correct visual state for the TabItem.
        /// </summary>
        /// <param name="useTransitions">
        /// true to use transitions when updating the visual state, false to
        /// snap directly to the new visual state.
        /// </param>
        private void ChangeVisualState(bool useTransitions)
        {
            // Choose the appropriate TabItem template to display
            // based on which TabStripPlacement we are using and
            // whether the item is selected.
            UpdateTabItemVisuals();

            // Update the CommonStates group
            if (!IsEnabled || (TabControlParent != null && !TabControlParent.IsEnabled))
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateDisabled, VisualStates.StateNormal);
            }
            else if (_isMouseOver && !IsSelected)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal);
            }

            // Update the SelectionStates group
            if (IsSelected)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected, VisualStates.StateUnselected);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnselected);
            }

            // Update the FocusStates group
            if (IsFocused && IsEnabled)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateFocused, VisualStates.StateUnfocused);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnfocused);
            }
        }
        /// <summary>
        /// Update the current visual state of the button.
        /// </summary>
        /// <param name="useTransitions">
        /// True to use transitions when updating the visual state, false to
        /// snap directly to the new visual state.
        /// </param>
        internal virtual void UpdateVisualState(bool useTransitions)
        {
            if (IsLocked)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateLocked);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnlocked);
            }

            switch (ExpandDirection)
            {
            case ExpandDirection.Down:
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandDown);
                break;

            case ExpandDirection.Up:
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandUp);
                break;

            case ExpandDirection.Left:
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandLeft);
                break;

            default:
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandRight);
                break;
            }

            // let the header know a change has possibly occured.
            if (ExpanderButton != null)
            {
                ExpanderButton.UpdateVisualState(useTransitions);
            }

            // Handle the Common and Focused states
            _interaction.UpdateVisualStateBase(useTransitions);
        }
        internal void ApplyState(bool useTransitions)
        {
            // Common States
            if (this.IsMouseOver)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal);
            }

            // Current States
            if (this.IsCurrent)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateCurrent, VisualStates.StateRegular);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateRegular);
            }

            // Expanded States
            if (this.RowGroupInfo.CollectionViewGroup.ItemCount == 0)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateEmpty);
            }
            else
            {
                if (this.RowGroupInfo.Visibility == Visibility.Visible)
                {
                    VisualStates.GoToState(this, useTransitions, VisualStates.StateExpanded, VisualStates.StateEmpty);
                }
                else
                {
                    VisualStates.GoToState(this, useTransitions, VisualStates.StateCollapsed, VisualStates.StateEmpty);
                }
            }
        }
Beispiel #7
0
        //-------------------------------------------------------------------
        //
        //  Protected Methods
        //
        //-------------------------------------------------------------------

        #region Protected Methods

        internal override void ChangeVisualState(bool useTransitions)
        {
            if (!IsEnabled)
            {
                VisualStateManager.GoToState(this, VisualStates.StateDisabled, useTransitions);
            }
            else if (IsMouseOver)
            {
                VisualStateManager.GoToState(this, VisualStates.StateMouseOver, useTransitions);
            }
            else
            {
                VisualStateManager.GoToState(this, VisualStates.StateNormal, useTransitions);
            }

            // Update the SelectionStates group
            if (IsSelected)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected, VisualStates.StateUnselected);
            }
            else
            {
                VisualStateManager.GoToState(this, VisualStates.StateUnselected, useTransitions);
            }

            if (IsKeyboardFocused)
            {
                VisualStateManager.GoToState(this, VisualStates.StateFocused, useTransitions);
            }
            else
            {
                VisualStateManager.GoToState(this, VisualStates.StateUnfocused, useTransitions);
            }

            base.ChangeVisualState(useTransitions);
        }
Beispiel #8
0
        /// <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);
                }
            }
        }
Beispiel #9
0
 // Token: 0x06005335 RID: 21301 RVA: 0x001723D4 File Offset: 0x001705D4
 internal override void ChangeVisualState(bool useTransitions)
 {
     if (!base.IsEnabled)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Disabled",
             "Normal"
         });
     }
     else if (base.IsMouseOver)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "MouseOver",
             "Normal"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Normal", useTransitions);
     }
     if (base.IsKeyboardFocused)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Focused",
             "Unfocused"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Unfocused", useTransitions);
     }
     base.ChangeVisualState(useTransitions);
 }
Beispiel #10
0
        /// <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,
                                                                  Properties.Resources.InvalidAttemptToChangeReadOnlyProperty, "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);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Change to the correct visual state for the Slider.
        /// </summary>
        /// <param name="useTransitions">
        /// true to use transitions when updating the visual state, false to
        /// snap directly to the new visual state.
        /// </param>
        internal void ChangeVisualState(bool useTransitions)
        {
            if (!IsEnabled)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateDisabled, VisualStates.StateNormal);
            }
            else if (IsMouseOver)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal);
            }

            if (IsFocused && IsEnabled)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateFocused, VisualStates.StateUnfocused);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnfocused);
            }
        }
 // Token: 0x060046EC RID: 18156 RVA: 0x00141BBC File Offset: 0x0013FDBC
 internal override void ChangeVisualState(bool useTransitions)
 {
     if (this.DataGridOwner == null)
     {
         return;
     }
     if (base.IsMouseOver)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "MouseOver",
             "Normal"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Normal", useTransitions);
     }
     if (this.IsSelected)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Selected",
             "Unselected"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Unselected"
         });
     }
     if (this.DataGridOwner.IsKeyboardFocusWithin)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Focused",
             "Unfocused"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Unfocused", useTransitions);
     }
     if (this.IsCurrent)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Current",
             "Regular"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Regular", useTransitions);
     }
     if (this.IsEditing)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Editing",
             "Display"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Display", useTransitions);
     }
     base.ChangeVisualState(useTransitions);
 }
 // Token: 0x06005937 RID: 22839 RVA: 0x0018A714 File Offset: 0x00188914
 internal override void ChangeVisualState(bool useTransitions)
 {
     if (!base.IsEnabled)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Disabled",
             "Normal"
         });
     }
     else if (base.IsMouseOver)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "MouseOver",
             "Normal"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Normal"
         });
     }
     if (base.IsKeyboardFocused)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Focused",
             "Unfocused"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Unfocused"
         });
     }
     if (this.IsExpanded)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Expanded"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Collapsed"
         });
     }
     if (base.HasItems)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "HasItems"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "NoItems"
         });
     }
     if (this.IsSelected)
     {
         if (this.IsSelectionActive)
         {
             VisualStates.GoToState(this, useTransitions, new string[]
             {
                 "Selected"
             });
         }
         else
         {
             VisualStates.GoToState(this, useTransitions, new string[]
             {
                 "SelectedInactive",
                 "Selected"
             });
         }
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Unselected"
         });
     }
     base.ChangeVisualState(useTransitions);
 }
Beispiel #14
0
        internal override void ChangeVisualState(bool useTransitions)
        {
            // Handle the Common states
            if (!IsEnabled)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateDisabled, VisualStates.StateNormal);
            }
            else if (IsMouseOver)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal);
            }

            // Handle the Focused states
            if (IsKeyboardFocused)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateFocused, VisualStates.StateUnfocused);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnfocused);
            }

            // Handle the Expansion states
            if (IsExpanded)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpanded);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateCollapsed);
            }

            // Handle the HasItems states
            if (HasItems)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateHasItems);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateNoItems);
            }

            // Handle the Selected states
            if (IsSelected)
            {
                if (IsSelectionActive)
                {
                    VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected);
                }
                else
                {
                    VisualStates.GoToState(this, useTransitions, VisualStates.StateSelectedInactive, VisualStates.StateSelected);
                }
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnselected);
            }

            base.ChangeVisualState(useTransitions);
        }
Beispiel #15
0
        internal void ApplyCellState(bool animate)
        {
            if (this.OwningGrid == null || this.OwningColumn == null || this.OwningRow == null || this.OwningRow.Visibility == Visibility.Collapsed || this.OwningRow.Slot == -1)
            {
                return;
            }

            // CommonStates
            if (this.IsMouseOver)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateNormal);
            }

            // SelectionStates
            if (this.OwningRow.IsSelected)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateSelected, VisualStates.StateUnselected);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateUnselected);
            }

            // FocusStates
            if (this.OwningGrid.ContainsFocus)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateFocused, VisualStates.StateUnfocused);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateUnfocused);
            }

            // CurrentStates
            if (this.IsCurrent)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateCurrent, VisualStates.StateRegular);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateRegular);
            }

            // Interaction states
            if (this.IsEdited)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateEditing, VisualStates.StateDisplay);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateDisplay);
            }

            // Validation states
            if (this.IsValid)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateValid);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateInvalid, VisualStates.StateValid);
            }
        }
        // Token: 0x06004B0D RID: 19213 RVA: 0x00152590 File Offset: 0x00150790
        internal override void ChangeVisualState(bool useTransitions)
        {
            if (!base.IsEnabled)
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Disabled",
                    "Normal"
                });
            }
            else if (base.IsMouseOver)
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "MouseOver",
                    "Normal"
                });
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Normal"
                });
            }
            if (base.IsKeyboardFocused)
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Focused",
                    "Unfocused"
                });
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Unfocused"
                });
            }
            if (this.IsExpanded)
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Expanded"
                });
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Collapsed"
                });
            }
            switch (this.ExpandDirection)
            {
            case ExpandDirection.Down:
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "ExpandDown"
                });
                break;

            case ExpandDirection.Up:
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "ExpandUp"
                });
                break;

            case ExpandDirection.Left:
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "ExpandLeft"
                });
                break;

            default:
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "ExpandRight"
                });
                break;
            }
            base.ChangeVisualState(useTransitions);
        }