I've tried using VisualStateManager.GetVisualStateGroups
in the OnAttached
override of my custom behavior, as well as in an event handler added to AssociatedObject.Loaded
event in that behavior. Both times I get an empty list.
Is there another way to get the visual state groups defined for a control, or another event handler I should attach to?
Be for it's asked, yes, the control has VisualStateGroups
and VisualStates
.
Based on Anthony's answer. Here I give an example for Metro App.
Usually the
VisualStateGroups
attached property is attached to the top levelFrameworkElement
in the control'sControlTemplate
. Hence to retrieve this value you may need to use theVisualTreeHelper
to get the first child of the control and see if that has aVisualStateGroups
property.