Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put a comparison in a multidatatrigger

How can we put a comparison in a MultiDataTrigger? Ina normal DataTrigger, we could put it as such:

<i:Interaction.Triggers>
       <ei:DataTrigger Binding="{Binding Count}" Comparison="LessThan" Value="5">
           <ei:ChangePropertyAction PropertyName="IsEnabled" Value="False"/>
       </ei:DataTrigger>
 </i:Interaction.Triggers>

But how do we put a comparison like this in a MultiDataTrigger condition? I searched, but couldn't find any solution. Please help. Thanks.

like image 282
Sangeetha Avatar asked Oct 25 '25 16:10

Sangeetha


1 Answers

You can use PropertyChangedTrigger (msdn):

In the below example we check condition is greater than 1 and less than 100 for Count property:

<TextBlock x:Name="textBlock" Background="Green" Text="{Binding Path=Count}">
    <i:Interaction.Triggers>
        <ei:PropertyChangedTrigger Binding="{Binding Path=Count}">
            <i:Interaction.Behaviors>
                <ei:ConditionBehavior>
                    <ei:ConditionalExpression>
                        <ei:ComparisonCondition LeftOperand="{Binding Count}" Operator="NotEqual" RightOperand="{x:Null}" />
                        <ei:ComparisonCondition LeftOperand="{Binding Count}" Operator="GreaterThan" RightOperand="1" />
                        <ei:ComparisonCondition LeftOperand="{Binding Count}" Operator="LessThan" RightOperand="100" />
                    </ei:ConditionalExpression>
                </ei:ConditionBehavior>                        
            </i:Interaction.Behaviors>
            <ei:ChangePropertyAction PropertyName="Background">
                <ei:ChangePropertyAction.Value>
                    <SolidColorBrush Color="Red"/>
                </ei:ChangePropertyAction.Value>
            </ei:ChangePropertyAction>
        </ei:PropertyChangedTrigger>            
    </i:Interaction.Triggers>
</TextBlock>
like image 99
kmatyaszek Avatar answered Oct 28 '25 07:10

kmatyaszek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!