-
Notifications
You must be signed in to change notification settings - Fork 140
DataStateBehavior
branh edited this page Dec 4, 2018
·
1 revision
DataStateBehavior performs an action when the data the behavior is bound to is equal to some value.
This behavior checks whenever the associated Binding
is updated to see if the result of the binding is equal to some Value
. If the two values are equal, it transitions to the TrueState
. Otherwise, it transitions to the FalseState
.
<Button x:Name="sampleStateButton">
<Button.Resources>
<Style TargetType="Button" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="BaseGrid" Background="DeepPink">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Normal">
<Storyboard>
<ColorAnimation Storyboard.TargetName="BaseGrid" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="DeepPink" From="DeepPink" />
</Storyboard>
</VisualState>
<VisualState x:Name="Blue">
<Storyboard>
<ColorAnimation Storyboard.TargetName="BaseGrid" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="DarkBlue" From="DarkBlue" Duration="Forever" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Behaviors:Interaction.Behaviors>
<Behaviors:DataStateBehavior Binding="{Binding Text, ElementName=MyText}" Value="" TrueState="Normal" FalseState="Blue" />
</Behaviors:Interaction.Behaviors>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Resources>
</Button>
- Introduction
- Contribution
- Behaviors Reference
- CallMethodAction
- ChangePropertyAction
- ConditionBehavior
- ControlStoryboardAction
- DataStateBehavior
- FluidMoveBehavior
- FluidMoveSetTagBehavior
- GoToStateAction
- InvokeCommandAction
- LaunchUriOrFileAction
- MouseDragElementBehavior
- PlaySoundAction
- RemoveElementAction
- SetDataStoreValueAction
- TranslateZoomRotateBehavior