Show / Hide Table of Contents

Class VisualStateManager

Manages states and the logic for transitioning between states for controls.

Inheritance
System.Object
DependencyObject
VisualStateManager
ExtendedVisualStateManager
Inherited Members
DependencyObject.GetValue(DependencyProperty)
DependencyObject.SetCurrentValue(DependencyProperty, Object)
DependencyObject.ReadLocalValue(DependencyProperty)
DependencyObject.SetValue(DependencyProperty, Object)
DependencyObject.SetValue(DependencyPropertyKey, Object)
DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs)
DependencyObject.CoerceValue(DependencyProperty)
DependencyObject.Dispatcher
DependencyObject.INTERNAL_OnAttachedToVisualTree()
DependencyObject.INTERNAL_OnDetachedFromVisualTree()
DependencyObject.ClearValue(DependencyProperty)
DependencyObject.ClearValue(DependencyPropertyKey)
DependencyObject.CheckAccess()
DependencyObject.GetAnimationBaseValue(DependencyProperty)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: System.Windows
Assembly: OpenSilver.dll
Syntax
public class VisualStateManager : DependencyObject, IDependencyObject

Fields

| Improve this Doc View Source

CustomVisualStateManagerProperty

Identifies the VisualStateManager.CustomVisualStateManager dependency property.

Declaration
public static readonly DependencyProperty CustomVisualStateManagerProperty
Field Value
Type Description
DependencyProperty

Methods

| Improve this Doc View Source

GetCustomVisualStateManager(FrameworkElement)

Gets the value of the VisualStateManager.CustomVisualStateManager attached property.

Declaration
public static VisualStateManager GetCustomVisualStateManager(FrameworkElement obj)
Parameters
Type Name Description
FrameworkElement obj

The element from which to get the VisualStateManager.CustomVisualStateManager.

Returns
Type Description
VisualStateManager

The VisualStateManager that transitions between the states of a control.

Exceptions
Type Condition
System.ArgumentNullException

obj is null.

| Improve this Doc View Source

GetVisualStateGroups(FrameworkElement)

Gets the value of the VisualStateManager.VisualStateGroups attached property.

Declaration
public static IList GetVisualStateGroups(FrameworkElement obj)
Parameters
Type Name Description
FrameworkElement obj

The element from which to get the VisualStateManager.VisualStateGroups.

Returns
Type Description
System.Collections.IList

The collection of VisualStateGroup objects that is associated with the specified object.

Exceptions
Type Condition
System.ArgumentNullException

obj is null.

| Improve this Doc View Source

GoToElementState(FrameworkElement, String, Boolean)

Transitions a control's state.

Declaration
public static bool GoToElementState(FrameworkElement stateGroupsRoot, string stateName, bool useTransitions)
Parameters
Type Name Description
FrameworkElement stateGroupsRoot

The root element that contains the VisualStateManager.

System.String stateName

The new state that the control is in.

System.Boolean useTransitions

Whether to use transition animations.

Returns
Type Description
System.Boolean

true if the state changed successfully, false otherwise.

| Improve this Doc View Source

GoToState(Control, String, Boolean)

Transitions the control between two states.

Declaration
public static bool GoToState(Control control, string stateName, bool useTransitions)
Parameters
Type Name Description
Control control

The control to transition between states.

System.String stateName

The state to transition to.

System.Boolean useTransitions

True to use a VisualTransition to transition between states; otherwise, false.

Returns
Type Description
System.Boolean

true if the control successfully transitioned to the new state; otherwise, false.

Exceptions
Type Condition
System.ArgumentNullException

control is null.

System.ArgumentNullException

stateName is null.

| Improve this Doc View Source

GoToStateCore(Control, FrameworkElement, String, VisualStateGroup, VisualState, Boolean)

Transitions a control between states.

Declaration
protected virtual bool GoToStateCore(Control control, FrameworkElement templateRoot, string stateName, VisualStateGroup group, VisualState state, bool useTransitions)
Parameters
Type Name Description
Control control

The control to transition between states.

FrameworkElement templateRoot

The root element of the control's ControlTemplate.

System.String stateName

The name of the state to transition to.

VisualStateGroup group

The VisualStateGroup that the state belongs to.

VisualState state

The representation of the state to transition to.

System.Boolean useTransitions

true to use a VisualTransition to transition between states; otherwise, false.

Returns
Type Description
System.Boolean

true if the control successfully transitioned to the new state; otherwise, false.

| Improve this Doc View Source

RaiseCurrentStateChanged(VisualStateGroup, VisualState, VisualState, Control)

Raises the CurrentStateChanged event on the specified VisualStateGroup.

Declaration
protected void RaiseCurrentStateChanged(VisualStateGroup stateGroup, VisualState oldState, VisualState newState, Control control)
Parameters
Type Name Description
VisualStateGroup stateGroup

The object on which the CurrentStateChanging event.

VisualState oldState

The state that the control transitioned from.

VisualState newState

The state that the control transitioned to.

Control control

The control that transitioned states.

Exceptions
Type Condition
System.ArgumentNullException

stateGroup is null or newState is null or control is null.

| Improve this Doc View Source

RaiseCurrentStateChanging(VisualStateGroup, VisualState, VisualState, Control)

Raises the CurrentStateChanging event on the specified VisualStateGroup.

Declaration
protected void RaiseCurrentStateChanging(VisualStateGroup stateGroup, VisualState oldState, VisualState newState, Control control)
Parameters
Type Name Description
VisualStateGroup stateGroup

The object on which the CurrentStateChanging event.

VisualState oldState

The state that the control is transitioning from.

VisualState newState

The state that the control is transitioning to.

Control control

The control that is transitioning states.

Exceptions
Type Condition
System.ArgumentNullException

stateGroup is null or newState is null or control is null.

| Improve this Doc View Source

SetCustomVisualStateManager(FrameworkElement, VisualStateManager)

Sets the value of the VisualStateManager.CustomVisualStateManager attached property.

Declaration
public static void SetCustomVisualStateManager(FrameworkElement obj, VisualStateManager value)
Parameters
Type Name Description
FrameworkElement obj

The object on which to set the property.

VisualStateManager value

The VisualStateManager that transitions between the states of a control.

Exceptions
Type Condition
System.ArgumentNullException

obj is null.

Extension Methods

DependencyObjectHelper.GetSelfAndAncestors(DependencyObject)
VisualTreeExtensions.GetVisualAncestors(DependencyObject)
VisualTreeExtensions.GetVisualAncestorsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualChildren(DependencyObject)
VisualTreeExtensions.GetVisualChildrenAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualDescendants(DependencyObject)
VisualTreeExtensions.GetVisualDescendantsAndSelf(DependencyObject)
VisualTreeExtensions.GetVisualSiblings(DependencyObject)
VisualTreeExtensions.GetVisualSiblingsAndSelf(DependencyObject)
  • Improve this Doc
  • View Source