Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 按钮启用绑定到组合框_C#_Xaml_Property Binding - Fatal编程技术网

C# 按钮启用绑定到组合框

C# 按钮启用绑定到组合框,c#,xaml,property-binding,C#,Xaml,Property Binding,我需要一个按钮禁用,直到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>

我需要一个按钮禁用,直到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>

绑定到textboes可以工作,但组合框不能。我应该写什么?谢谢


<DataTrigger Binding="{Binding SelectedIndex, ElementName=cmb}" Value="-1">
         <Setter Property="IsEnabled" Value="False" />
  </DataTrigger>
未选择任何项目时,SelectedIndex将为-1