WPF RadioButton 样式 (1)_ci

界面

<RadioButton x:Name="radioButton" IsChecked="True"  Content="界面" HorizontalAlignment="Left" Height="90" Margin="100,334,0,0" VerticalAlignment="Top" Width="60" Style="{DynamicResource RadioButtonOISStyle}"/>
<RadioButton x:Name="radioButton_Copy" Content="用户管理" HorizontalAlignment="Right" Height="90" Margin="0,334,100,0" VerticalAlignment="Top" Width="70" Style="{DynamicResource RadioButtonAdminStyle}"/>

样式

<Style x:Key="RadioButtonOISStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background" Value="{StaticResource CheckRadioFillNormal}"/>
<Setter Property="BorderBrush" Value="{StaticResource CheckRadioStrokeNormal}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid Margin="0,0,0,-4.11" Width="60" Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="31*"/>
<RowDefinition Height="11*"/>
</Grid.RowDefinitions>
<!--背景颜色 透明度 边框弧度-->
<Rectangle x:Name="rectangle" Fill="{x:Null}" Stroke="{x:Null}" Opacity="1" RadiusX="0" RadiusY="0" StrokeThickness="0" Grid.RowSpan="1"/>
<Image x:Name="image" Source="/OIS;component/Resources/Images/oisB.png" Grid.RowSpan="1" Height="Auto" HorizontalAlignment="Center" Width="60" Margin="0,4.5" />
<!--字体颜色, 字体大小-->
<TextBlock x:Name="textBlock" Margin="0" TextWrapping="Wrap" Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Stretch" Height="22" FontSize="16" Foreground="#FFACADAE" Grid.RowSpan="1" Grid.Row="1" Width="33"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="GroupName" Value=""/>
<Trigger Property="GroupName" Value=""/>
<!--鼠标点击触发器, 背景颜色-->
<Trigger Property="IsChecked" Value="True">

<Setter Property="Opacity" TargetName="rectangle" Value="1"/>
<Setter Property="Source" TargetName="image" Value="/OIS;component/Resources/Images/oisA.png"/>
<Setter Property="Foreground" TargetName="textBlock" Value="#FF1AB394"/>
</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="RadioButtonAdminStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background" Value="{StaticResource CheckRadioFillNormal}"/>
<Setter Property="BorderBrush" Value="{StaticResource CheckRadioStrokeNormal}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid Margin="0,0,0,-4.11" Width="70" Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="31*"/>
<RowDefinition Height="11*"/>
</Grid.RowDefinitions>
<!--背景颜色 透明度 边框弧度-->
<Rectangle x:Name="rectangle" Fill="{x:Null}" Stroke="{x:Null}" Opacity="1" RadiusX="0" RadiusY="0" StrokeThickness="0" Grid.RowSpan="1"/>
<Image x:Name="image" Source="/OIS;component/Resources/Images/AdminB.png" Grid.RowSpan="1" Height="Auto" HorizontalAlignment="Center" Width="60" Margin="0,4.5" />
<!--字体颜色, 字体大小-->
<TextBlock x:Name="textBlock" Margin="0" TextWrapping="Wrap" Text="{TemplateBinding Content}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="22" FontSize="16" Foreground="#FFACADAE" Grid.RowSpan="1" Grid.Row="1" Width="Auto"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="GroupName" Value=""/>
<Trigger Property="GroupName" Value=""/>
<!--鼠标点击触发器, 背景颜色-->
<Trigger Property="IsChecked" Value="True">

<Setter Property="Opacity" TargetName="rectangle" Value="1"/>
<Setter Property="Source" TargetName="image" Value="/OIS;component/Resources/Images/adminA.png"/>
<Setter Property="Foreground" TargetName="textBlock" Value="#FF1AB394"/>
</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>