VisualStateManager.CustomVisualStateManager attached property

VisualStateManager.CustomVisualStateManager attached property

Gets or sets the custom VisualStateManager object that handles transitions between the states of a control.

<templateRoot VisualStateManager.CustomVisualStateManager="reference" />


XAML Values


The root UIElement as defined within a control template.


An inline reference to an existing custom VisualStateManager instance. This might be a binding or a {StaticResource} markup extension usage to an object defined in a ResourceDictionary.


Exactly one object element for a class that implements VisualStateManager. This is typically mapped to a custom xmlns namespace. For example: <local:MyCustomStateMgr/> where "local" is a prefix that maps to the code namespace where the "MyCustomStateMgr" class is defined.


This attached property is only needed for cases where you want to use a custom implementation class to handle your app's visual state changes, rather than the default VisualStateManager class implemented by the Windows Runtime. If you don't intend to use a custom implementation, you don't need to set this property.

If you want to implement your own logic for transitions between states, create a class that inherits from VisualStateManager, and override the GoToStateCore method. To use the custom class, set the VisualStateManager.CustomVisualStateManager attached property to an instance of your custom type. You also might want to override some of the event logic (RaiseCurrentStateChanged, RaiseCurrentStateChanging).

To reference your custom VisualStateManager class, set the value of the VisualStateManager.CustomVisualStateManager attached property within any control template where you want to use the custom VisualStateManager class behavior. You typically create an instance of the custom VisualStateManager class through default XAML construction in Application.Resources. Then the VisualStateManager.CustomVisualStateManager attached property is set using a {StaticResource} markup extension reference to the key of the custom VisualStateManager resource.

VisualStateManager.CustomVisualStateManager is an attached property, which supports a XAML usage. When getting this property in code, use GetCustomVisualStateManager. When setting this property in code, use SetCustomVisualStateManager instead. In code usages, the target parameter is the object where the attached property value is set. Another way to get or set the value in code is to use the dependency property system, calling either GetValue or SetValue and passing CustomVisualStateManagerProperty as the dependency property identifier.

Requirements (Windows 10 device family)

Device family

API contract




Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]





See also

Attached properties overview
Quickstart: Control templates



© 2017 Microsoft