添加图标
定义样式
<Style x:Key="radBase" TargetType="RadioButton">
<Setter Property="IsChecked" Value="False" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#555" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<DockPanel Background="{TemplateBinding Background}" ToolTip="{TemplateBinding Content}" LastChildFill="False" Width="{TemplateBinding Width}">
<Image Margin="2 0 0 0" DockPanel.Dock="Left" x:Name="_img" Stretch="None" Source="/resource/no.png" />
<TextBlock DockPanel.Dock="Left" Margin="3 0 0 0" VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" />
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="_img" Property="Source" Value="/resource/yes.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
使用
<WrapPanel Grid.Row="2" HorizontalAlignment="Left" Orientation="Vertical" Margin="10">
<RadioButton Content="111" Style="{StaticResource radBase}" Width="80" Height="60" />
<RadioButton Content="222" Style="{StaticResource radBase}" Width="80" Height="60" />
<RadioButton Content="333" Style="{StaticResource radBase}" Width="80" Height="60" />
</WrapPanel>
效果