How could I change the Canvas.Zindex of an object using visual states? I was expecting to be able to do something like this..
<VisualState x:Name="MyVisualState">
<VisualState.Setters>
<Setter Target="MyObject.Visibility" Value="Visible" />
<Setter Target="MyObject.Background" Value="Transparent" />
<Setter Target="MyObject.Canvas.ZIndex" Value="12" />
</VisualState.Setters>
</VisualState>
But this does not work. I have not been able to find any examples on how to do this. Can someone help?
Here you go. Note you need the
()
there becauseCanvas.ZIndex
is an attached property and that's how you define the value of it in XAML.You might be interested in this answer which will show you how to generate the code above without writing a single line of code.