I know this Question is similar to many. Anyway, I don't understand.
I have a several VisualStates (more than 2, thats why DataStateBehavior is not my solution). And I have ViewModel, which have enum property CurrentState. Every enum value represents to one state, also may be several enum values represents to one states, doesn't metter. I want VisualState changed when the CurrentState changed (thought, that immediately appears in my mind : Binding was created exactly for this case!)
Can I bind CurrentState with view VisualState (xaml-only solution), to get the behavior described above?
If yes, how can I do it?
If no, how should I use VisualStateManager.GoToState() method in my ViewModel?
I wanted to note a solution similar to @FasterSolutions', using built-in components of the Blend SDK.
Set a PropertyChangedTrigger
on the view-model's "CurrentState" property, and add a GoToStateAction
to change the visual state:
<i:Interaction.Triggers
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions">
<ei:PropertyChangedTrigger Binding="{Binding CurrentState}">
<ei:GoToStateAction StateName="{Binding CurrentState}" />
</ei:PropertyChangedTrigger>
</i:Interaction.Triggers>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With