为什么<style targettype =“{x:Type Control}”>不起作用?</style>

时间:2014-12-22 12:27:21

标签: c# wpf xaml wpf-style targettype

我有CheckBoxRadioButtonTextBox,并希望使用绑定来控制其启用:

<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,对吧?

0 个答案:

没有答案