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}"/>
不能,因爲我一直在使用這些樣式其他UI元素。 – Conrad
可以請你分享一下UI結構嗎?如何聲明單選按鈕以及在哪裏? –
我不確定你在找什麼 - 「UI結構」是什麼意思?一個不會「聲明」一個RadioButton。 – Conrad