So my xaml code looks like this -
<Grid x:Name="LayoutRoot">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
I can't use the GoToVisualState
behavior because I need to do some checks before running this animation. So I guess I will have to call something like GoToState
or GoToElementState
in code behind.
However, ExtendedVisualStateManager
doesn't seem to exist in WinRT. I tried using
VisualStateManager.GetCustomVisualStateManager(this.LayoutRoot)
but it always returns null
.
Is there any workaround for this?
Typically I have a single
UpdateVisualState(bool useTransitions)
method in my controls that makes all theGoToVisualState()
calls. If something can't be animated then I see two options:UpdateVisualState()
method. The drawback of this solutions is that Blend will not show the change in the visual state editor. I don't personally care though because I rarely use Blend on already integrated designs and this solution is simple.Storyboard
. That's a bit more work, but could keep Blend support in your project.Just figured this out.
First create a helper class just like how we used to use it in Silverlight or Windows Phone (I took this piece of code from here and modified it a little bit so when an element doesn't have any visual state groups attached, it automatically goes search for its parent until it finds any).
Then you will need to manually update the xaml to something like this -
I guess the good thing about this solution is that you can still see the visual states in Blend's States tab, for Blend lovers this is just cool.