Home > database >  WPF - Border around Radio Button and Content
WPF - Border around Radio Button and Content

Time:12-08

I've been searching around and could not find an answer to what seems like an easy thing.

How can I create a border outline around a WPF RadioButton and its contents? (See picture below)

Outlined radio buttons

I tried to use BorderBrush and BorderThickness but that applies to the "button itself" (the circle), not the entire thing.

<Style x:Key="RadioStyle" TargetType="RadioButton">
    <Setter Property="BorderBrush" Value="AliceBlue"/>
    <Setter Property="BorderThickness" Value="1"/>
</Style>
<RadioButton ...  Style="{StaticResource RadioStyle}">
    Radio1
</RadioButton>

CodePudding user response:

Either create a custom ControlTemplate for the RadioButton or explicitly wrap the entire RadioButton in a Border:

<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left">
    <RadioButton Content="..." />
</Border>
  • Related