0

How is that you can declare VisualStates and VisualStateGroups on any object inheriting from FrameworkElement but to call the VisualStateManager.GoToState you need to specify a Control? What's the point of declaring states tan you cannot navigate to them?

This looks like an inconsistency to me. Am I right or am I missing something?

Thanks in advance

Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207

1 Answers1

1

The VisualStateManager.VisualStateGroups property is set on the root element of a ControlTemplate, which can be a FrameworkElement like a Panel. However, the control parameter of the GoToState() method is NOT the root element of the template, it is the Control itself, which has the ControlTemplate bound to it.

A bit confusing? Maybe. Not very OOP? Absolutely.

Aleksandr Dubinsky
  • 22,436
  • 15
  • 82
  • 99