jueves, 15 de octubre de 2009

Implementing CustomVisualStateManagers to see in which visual state is your object

Technology: Silverlight 3.0

Problem: I need to know which method from Silverlight framework changes the VisualState of a control and when.

Solution: Develop a Custom VisualStateManager and override the GoToStateCore method (which is the only method that can be overriden), doing a Debug.WriteLine with Debug information. I decided to write the information on debug instead of setting a breakpoint, because the breakpoint might alter the behavior of the VisualStateManager. Another thing to remember is to call the base method when overriding GoToStateCore.

In order to set the CustomVisualStateManager as the default VisualStateManager to handle the changes, you can set the XAML in this way:

You could also set it through the static method: VisualStateManager.SetCustomVisualStateManager(FrameworkElement,VisualStateManager);

No hay comentarios:

Publicar un comentario