2016-08-05 81 views
1

[使用.NET Framework 4.5.1]单选按钮样式属性Padding没有被应用

我有以下的资源在我的WPF的Windows来设置:

<Window.Resources> 
    <Style TargetType="{x:Type FrameworkElement}" x:Key="baseStyle"> 
     <Setter Property="Margin" Value="5"/> 
     <Setter Property="VerticalAlignment" Value="Center"/> 
    </Style> 
    <Style TargetType="{x:Type FrameworkElement}" x:Key="basePlusEnabled" BasedOn="{StaticResource baseStyle}"> 
     <Setter Property="IsEnabled" Value="{Binding TestIsRunning, Mode=OneWay}"/> 
    </Style> 
    <Style TargetType="RadioButton" BasedOn="{StaticResource basePlusEnabled}"> 
     <Setter Property="Padding" Value="4,-5,0,0"/> 
     <Setter Property="HorizontalAlignment" Value="Left"/> 
     <Setter Property="Foreground" Value="{Binding TestIsRunning, 
      Converter={StaticResource testIsRunningForegroundConverter}, Mode=OneWay}"/> 
    </Style> 
</Window.Resources> 

然而,Padding风格不应用于窗口中的RadioButton。 (样式中的其他属性正在应用。)如果我明确指定RadioButton中的Padding,那么它就可以工作。我在这里错过了什么?

编辑: 样品RadioButton例如:

<RadioButton Grid.Column="4" Content="Iowa" GroupName="Facility" 
    IsChecked="{Binding IowaFacilityChecked1, UpdateSourceTrigger=PropertyChanged, 
    Mode=TwoWay}"/> 

回答

0

变化TargetType="{x:Type FrameworkElement}"TargetType="{x:Type RadioButton}"

+0

不能,因为我一直在使用这些样式其他UI元素。 – Conrad

+0

可以请你分享一下UI结构吗?如何声明单选按钮以及在哪里? –

+0

我不确定你在找什么 - “UI结构”是什么意思?一个不会“声明”一个RadioButton。 – Conrad