0

我试图让一个按钮处于禁用状态,直到两个 DataGrids 至少有一个选定的项目。目前它仍处于启用状态。

<Button MaxWidth="200" Grid.Column="0" x:Name="Add" Content="{x:Static UiStrings:Labels.Add}" >
    <Button.Style>
        <Style TargetType="Button">
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Path=SelectedIndex, ElementName=EconomicFactors}" Value="-1"></Condition>
                        <Condition Binding="{Binding Path=SelectedIndex, ElementName=TargetTypes}" Value="-1"></Condition>
                    </MultiDataTrigger.Conditions>
                    <Setter Property="IsEnabled" Value="False"/>
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </Button.Style>
</Button>

问候,

4

1 回答 1

3

MultiDataTrigger所有条件下都必须为真。我认为最简单的解决方案是MultiDataTrigger用两个替换DataTrigger

<Style.Triggers>
    <DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=EconomicFactors}" Value="-1">
        <Setter Property="IsEnabled" Value="False"/>
    </DataTrigger>
    <DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=TargetTypes}" Value="-1">
        <Setter Property="IsEnabled" Value="False"/>
    </DataTrigger>
</Style.Triggers>
于 2013-05-24T12:53:07.743 回答