From 6341f28f08832d97b2cb3b3d856b39c5ef128d6d Mon Sep 17 00:00:00 2001 From: "Patrick M. Decoster" Date: Tue, 23 Apr 2019 18:45:12 +0200 Subject: [PATCH 1/8] Split DataTrigger Sample into GreaterThan and Enum section. Implemented DataTrigger with Enum sample --- .../DataTriggerControl.xaml | 145 ++++++++++++------ .../DataTriggerControl.xaml.cs | 48 +++++- .../XAMLBehaviorsSample.csproj | 14 +- samples/CS/XAMLBehaviorsSample/project.json | 16 -- 4 files changed, 156 insertions(+), 67 deletions(-) delete mode 100644 samples/CS/XAMLBehaviorsSample/project.json diff --git a/samples/CS/XAMLBehaviorsSample/DataTriggerControl.xaml b/samples/CS/XAMLBehaviorsSample/DataTriggerControl.xaml index 961b43b7..e5f73c4c 100644 --- a/samples/CS/XAMLBehaviorsSample/DataTriggerControl.xaml +++ b/samples/CS/XAMLBehaviorsSample/DataTriggerControl.xaml @@ -11,30 +11,74 @@ d:DesignWidth="800"> - - - - + + + + + + + - - - - - - - - - + + + + + DataTriggerBehavior performs an action when the data the behaviors is bound to meets a specified condition. + In this example, when the bound data of the slider's value reaches above 50, the behavior triggers an action to change the color of the rectangle. + + + + <Rectangle x:Name="DataTriggerRectangle"> + <Interactivity:Interaction.Behaviors> + <Interactions:DataTriggerBehavior Binding="{Binding Value, ElementName=slider}" ComparisonCondition="GreaterThan" Value="50"> + <Interactions:ChangePropertyAction TargetObject="{Binding ElementName=DataTriggerRectangle}" PropertyName="Fill" Value="{StaticResource PaleYellowBrush}"/> + </Interactions:DataTriggerBehavior> + <Interactions:DataTriggerBehavior Binding="{Binding Value, ElementName=slider}" ComparisonCondition="LessThanOrEqual" Value="50"> + <Interactions:ChangePropertyAction TargetObject="{Binding ElementName=DataTriggerRectangle}" PropertyName="Fill" Value="{StaticResource RoyalBlueBrush}"/> + </Interactions:DataTriggerBehavior> + </Interactivity:Interaction.Behaviors> +</Rectangle> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - DataTriggerBehavior performs an action when the data the behaviors is bound to meets a specified condition. + + + + + DataTriggerBehavior performs an action when the data the behaviors is bound to meets a specified condition. In this example, when the bound data of the slider's value reaches above 50, the behavior triggers an action to change the color of the rectangle. - - - + + + <Rectangle x:Name="DataTriggerRectangle"> <Interactivity:Interaction.Behaviors> <Interactions:DataTriggerBehavior Binding="{Binding Value, ElementName=slider}" ComparisonCondition="GreaterThan" Value="50"> @@ -46,29 +90,42 @@ </Interactivity:Interaction.Behaviors> </Rectangle> - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + + + + + + +