wpf 自定义 RadioButton.

  <Style TargetType="RadioButton" x:Key="nav">

            <Setter Property="Template">

                <Setter.Value>

                    <ControlTemplate TargetType="RadioButton">

                        <Border x:Name="b" Background="Transparent" CornerRadius="8">

                            <ContentControl Content="{TemplateBinding Content}" VerticalAlignment="Center"></ContentControl>

                        </Border>

                        <ControlTemplate.Triggers>

                            <Trigger Property="IsChecked" Value="True">

                                <Setter TargetName="b" Property="Background" Value="red"></Setter>

                            </Trigger>

                        </ControlTemplate.Triggers>

                    </ControlTemplate>

                </Setter.Value>

            </Setter>

        </Style>

 

-----------------------------------------------------------------------------------------------------------------

使用

  <RadioButton  Style="{StaticResource nav}"  x:Name="n1">1111111</RadioButton>

上一篇:WPF RadioButton单选框绑定 Binding


下一篇:Android常用控件之RadioButton单选按钮