WPF:具有多个属性条件的DataTrigger

时间:2019-02-11 19:01:39

标签: wpf datatrigger multibinding

所以我有这个DataTrigger

<DataTrigger Binding="{Binding Path=IsFilesSelected}" Value="True">
    <DataTrigger.EnterActions>
        <StopStoryboard BeginStoryboardName="EndAnimation"/>
        <BeginStoryboard Name="NewAnimation">
            <Storyboard>
                <ThicknessAnimation Storyboard.TargetProperty="Margin"                                                                        
                                    From="0,50,0,0"                                                                         
                                    To="0,0,0,0"                                                                       
                                    DecelerationRatio=".9"                                                                   
                                    Duration="0:0:0.3" />
            </Storyboard>
        </BeginStoryboard>
    </DataTrigger.EnterActions>
</DataTrigger>

正如您所看到的,当我的DataTrigger属性更改为IsFilesSelected时,True开始了,我想知道如何分配另一个属性,并在确定是否需要开始我的DataTrigger

1 个答案:

答案 0 :(得分:1)

您要寻找的是MultiDataTriggerdocumentation here

  

代表一个触发器,当绑定数据满足一组条件时,该触发器将应用属性值或执行操作。

从MSDN网站提取的示例

<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding Path=Name}" Value="Portland" />
        <Condition Binding="{Binding Path=State}" Value="OR" />
    </MultiDataTrigger.Conditions>
    <Setter Property="Background" Value="Cyan" />
</MultiDataTrigger>

Background ==“ Portland” AND Name ==“ OR”时,上面的示例将设置State属性。