Reputation: 1495
I don't have very much experience with XAML or expression blend yet. I am trying to make the initial visualState of my silverlight application be defined by a string binding.
So far, I am simply making a manual trigger for each possible visualstate:
<i:Interaction.Triggers>
<ei:DataTrigger Binding="{Binding VisualState}" Value="DevOffline">
<ei:GoToStateAction StateName="DevOffline"/>
</ei:DataTrigger>
<ei:DataTrigger Binding="{Binding VisualState}" Value="Public">
<ei:GoToStateAction StateName="Public"/>
</ei:DataTrigger>
....
</i:Interaction.Triggers>
It works, but I have 9 states in total, so I would like something universal like:
<goToStateAction StateName="{Binding VisualState}" />
Is it possible to do this? If so, where do I put it in my XAML? The same place?
Upvotes: 2
Views: 1387
Reputation: 6460
The StateName property on the GoToStateAction behavior is a dependency property, so it seems like you should be able to bind to it. Just replace the DataTrigger with a PropertyChangedTrigger. It seems like you should be able to do the following:
<i:Interaction.Triggers>
<ei:PropertyChangedTrigger Binding="{Binding VisualState}">
<ei:GoToStateAction StateName="{Binding VisualState}"/>
</ei:PropertyChangedTrigger >
</i:Interaction.Triggers>
Upvotes: 3