How can I know which VisualState of control already defined in WPF's XAML?

89 Views Asked by At

How can I know which VisualState of control already defined in XAML?

For example, WPF Button control has 2 VisualStateGroups by default. They are "CommonStates" and "FocusStates". The "CommonStates" contains 4 VisualState: "Normal", "MouseOver", "Pressed", "Disabled". These states already have default handlers so when the mouse over or pressed, Button's VisualState changes corresponding. Thank you for reading!

2

There are 2 best solutions below

0
Alex.Wei On

The wpf designer of visual studio has an "edit template" function. You can use that to veiw any control's default template. You can do that by follow the steps:

  1. Add the control to designer correctly.
  2. Right click the control -> Edit Template -> Edit a Copy.

If you can't do that, you still can get templates of standard wpf controls from msdn https://learn.microsoft.com/dotnet/framework/wpf/controls/control-styles-and-templates

0
namhnz On

I just have found the list of VisualState which is built-in with Button control right here: Button VisualStates

You can also find the list for other control there.