-
-
Notifications
You must be signed in to change notification settings - Fork 59
CompositeStateTrigger
Morten Nielsen edited this page Jun 9, 2015
·
1 revision
This trigger will trigger if all or one of a collection of other triggers are active. The triggers used must implement IValueTrigger.
Properties:
-
Operator
: And (all), Xor (one) or Or (any).
#Examples
Greater than and less than combined to a "between" composite trigger by using an AND operator
<VisualState x:Name="between">
<VisualState.StateTriggers>
<triggers:CompositeStateTrigger Operator="And">
<triggers:CompareStateTrigger Value="{x:Bind slider.Value, Mode=OneWay}" CompareTo="3" Comparison="GreaterThan" />
<triggers:CompareStateTrigger Value="{x:Bind slider.Value, Mode=OneWay}" CompareTo="7" Comparison="LessThan" />
</triggers:CompositeStateTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="sliderStatus.Text" Value="Slider value is between 3 and 7" />
</VisualState.Setters>
</VisualState>
Require only one checkbox to be checked by using the XOR operator
<VisualState x:Name="OnlyCheckOne">
<VisualState.StateTriggers>
<triggers:CompositeStateTrigger Operator="Xor">
<triggers:CompareStateTrigger Value="{x:Bind chb1.IsChecked.Value, Mode=OneWay}" CompareTo="True" Comparison="Equal" />
<triggers:CompareStateTrigger Value="{x:Bind chb2.IsChecked.Value, Mode=OneWay}" CompareTo="True" Comparison="Equal" />
<triggers:CompareStateTrigger Value="{x:Bind chb3.IsChecked.Value, Mode=OneWay}" CompareTo="True" Comparison="Equal" />
</triggers:CompositeStateTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="selectionStatus.Text" Value="You have selected one value" />
<Setter Target="submitButton.IsEnabled" Value="True" />
</VisualState.Setters>
</VisualState>
Trigger when no check boxes are checked by using AND operator on a false-value check
<VisualState x:Name="NoneSelected">
<VisualState.StateTriggers>
<triggers:CompositeStateTrigger Operator="And">
<triggers:CompareStateTrigger Value="{x:Bind chb1.IsChecked.Value, Mode=OneWay}" CompareTo="False" Comparison="Equal" />
<triggers:CompareStateTrigger Value="{x:Bind chb2.IsChecked.Value, Mode=OneWay}" CompareTo="False" Comparison="Equal" />
<triggers:CompareStateTrigger Value="{x:Bind chb3.IsChecked.Value, Mode=OneWay}" CompareTo="False" Comparison="Equal" />
</triggers:CompositeStateTrigger>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="selectionStatus.Text" Value="Please check one item" />
</VisualState.Setters>
</VisualState>