ArmandoS63
ArmandoS63

Reputation: 703

Is it possible to style BorderThickness of RadioButton?

I'd like to change the BorderThickness of a RadioButton. Is this possible?
This is what I've got so far:

<Style TargetType="RadioButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RadioButton">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderThickness" Storyboard.TargetName="Border">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="6" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <!-- ... -->        
                        </VisualStateManager.VisualStateGroups>             
                    </Border>                   
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

I read this post but somehow it's not working for me because:

The name "ThicknessAnimation" does not exist in the namespace "http://schemas.microsoft.com/client/2007"

Any ideas?

Upvotes: 0

Views: 283

Answers (1)

Martin
Martin

Reputation: 6146

To answer your question: yes, it is possible to style the BorderThickness of the RadioButton control. In what context do you want to change the BorderThickness? In order to have one particular button show a thicker border just set the property accordingly:

<RadioButton x:Name="MyNiceFoobarButton" BorderThickness="6"/>

If you want all your RadioButtons to have a thicker border you have to use a Style:

<Style TargetType="RadioButton">
    <Setter Property="BorderThickness" Value="6"/>
</Style>

[Edit] And if you want your button to show a thicker border only while a paticular VisualState is active you have to overwrite the ControlTemplate and specify all VisualStates with their corresponding animations.

Upvotes: 1

Related Questions