There is no property that lists a controls states.
According to MSDN Control Authors must provide a control contract
so that ControlTemplate authors will know what to put in the template.
A control contract has three elements:
- The visual elements that the control's logic uses.
- The states of the control and the group each state belongs to.
- The public properties that visually affect the control.
both the visual element and the states are provided as Class Attributes
[TemplatePart(Name = "XXX", Type = typeof(RepeatButton))]
[TemplatePart(Name = "YYY", Type = typeof(RepeatButton))]
[TemplateVisualState(Name = "Focused", GroupName = "FocusedStates")]
[TemplateVisualState(Name = "Unfocused", GroupName = "FocusedStates")]
you should go over the default Control Styles and Templates I think all the dat you are looking for will be there.
if you have to get the data in run time then you can use Reflection
to get a given class Attributes like that :
System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes(true);
for (int i = 0; i < attributes.Length; i++)
{
if (attributes[i] is TemplatePart || attributes[i] is TemplateVisualState)
{
System.Console.WriteLine(((TemplateVisualState) attributes[i]).Name);
}
}
read this MSDN Article it will make things clearer