使用.NET框架4.5.1
我在其中一个WPF窗口中设置了以下资源:
<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>但是,窗口中的RadioButton没有应用Padding样式。(将应用该样式中的其他特性。)如果我在每个RadioButton中显式地指定了Padding,那么它就可以工作。这里我漏掉了什么?
编辑:示例RadioButton实例:
<RadioButton Grid.Column="4" Content="Iowa" GroupName="Facility"
IsChecked="{Binding IowaFacilityChecked1, UpdateSourceTrigger=PropertyChanged,
Mode=TwoWay}"/>发布于 2016-08-06 01:23:35
将TargetType="{x:Type FrameworkElement}"更改为TargetType="{x:Type RadioButton}"
https://stackoverflow.com/questions/38793293
复制相似问题