我有CheckBox
,RadioButton
和TextBox
,并希望使用绑定来控制其启用:
<Grid.Resources>
<Style TargetType="{x:Type CheckBox}"> <Setter Property="IsEnabled" Value="{Binding IsNotScanning}"/> </Style>
<Style TargetType="{x:Type RadioButton}"> <Setter Property="IsEnabled" Value="{Binding IsNotScanning}"/> </Style>
<Style TargetType="{x:Type TextBox}"> <Setter Property="IsEnabled" Value="{Binding IsNotScanning}"/> </Style>
</Grid.Resources>
这很好,但为什么以下不起作用?
<Grid.Resources>
<Style TargetType="{x:Type Control}">
<Setter Property="IsEnabled" Value="{Binding IsNotScanning}"/>
</Style>
</Grid.Resources>
毕竟,他们都继承了Control
,对吧?