Skip to content

GoToStateAction

Jon W Chu edited this page Nov 16, 2015 · 1 revision

GoToStateAction represents an action that will transition a FrameworkElement (i.e. Button) to a specified VisualState when triggered.

This Behavior turns the specified TargetObject to the VisualState of StateName when triggered. Additionally, the change in VisualState can utilize transitions when the UseTransitions property is set to true.

Sample Code

XAML

<CheckBox x:Name="checkBox">
    <Interactivity:Interaction.Behaviors>
        <Interactions:DataTriggerBehavior Binding="{Binding IsChecked, ElementName=checkBox}" Value="True">
            <Interactions:GoToStateAction StateName="Disabled" TargetObject="{Binding ElementName=sampleStateButton}"/>
        </Interactions:DataTriggerBehavior>
        <Interactions:DataTriggerBehavior Binding="{Binding IsChecked, ElementName=checkBox}" Value="False">
            <Interactions:GoToStateAction StateName="Normal" TargetObject="{Binding ElementName=sampleStateButton}"/>
        </Interactions:DataTriggerBehavior>
    </Interactivity:Interaction.Behaviors>
</CheckBox>