0

我需要禁用一个按钮,直到 3 个文本框为空并且在组合框上没有进行任何选择。我编写了以下 XAML 代码:

<Button x:Name="previewBtn" Content="Anteprima" HorizontalAlignment="Left" Margin="164,33,0,0" VerticalAlignment="Top" Width="75" Height="19" Click="previewBtn_Click_1">
        <Button.Style>
            <Style TargetType="Button">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Text.Length, ElementName=titleBox}" Value="0">
                        <Setter Property="IsEnabled" Value="False" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Text.Length, ElementName=StEpLabel}" Value="0">
                        <Setter Property="IsEnabled" Value="False" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Text.Length, ElementName=seasonBox}" Value="0">
                        <Setter Property="IsEnabled" Value="False" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedIndex, ElementName=cmb}" Value="0">
                        <Setter Property="IsEnabled" Value="False" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Button.Style>
    </Button>

绑定到文本框有效,但组合框无效。我应该写什么?谢谢

4

1 回答 1

1
<DataTrigger Binding="{Binding SelectedIndex, ElementName=cmb}" Value="-1">
         <Setter Property="IsEnabled" Value="False" />
  </DataTrigger>

未选择任何项目时,SelectedIndex 将为 -1。

于 2018-07-12T05:21:06.703 回答