tags:

views:

184

answers:

2

How do I programmatically get the current Visual State of a WPF FrameworkElement? And by state I mean the states like "Normal", "MouseOver", "Disabled", etc.

EDIT: Basically, I am changing the Visual state of a button with VisualStateManager.GoToState(e, "MouseOver", true);, and I want to know what state to change it back to after I am done.

A: 

There is no notion of "visual state" in WPF, but you can check the following properties : IsMouseOver, IsEnabled...

Thomas Levesque
There is in WPF 4.0 with the VisualStateManager.
Kyle
+1  A: 

I think you have to know/remember the button state by yourself. VSM just displays the state in which the button is by GoToState method.

Edit: I've just found an article how to create a custom VSM that remembers control states.

Lukas Cenovsky