Circled Radio Buttons : RadioButton « Windows Presentation Foundation « C# / CSharp Tutorial






<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Page.Resources>
        <ControlTemplate x:Key="newradio" 
                         TargetType="{x:Type RadioButton}">
            <Border Name="border" BorderBrush="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
                    Padding="10"
                    CornerRadius="100">
                <ContentPresenter />
            </Border>

            <ControlTemplate.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter TargetName="border"
                            Property="BorderThickness"
                            Value="3" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Page.Resources>

    <GroupBox Header="Options" FontSize="20pt">
        <StackPanel>
            <RadioButton Template="{StaticResource newradio}"
                         HorizontalAlignment="Center" 
                         Content="1" />
            <RadioButton Template="{StaticResource newradio}"
                         HorizontalAlignment="Center"
                         Content="2"
                         IsChecked="True" />
            <RadioButton Template="{StaticResource newradio}"
                         HorizontalAlignment="Center"
                         Content="3" />
        </StackPanel>
    </GroupBox>
</Page>
WPF Circled Radio Buttons








24.21.RadioButton
24.21.1.Checked RadioButtonChecked RadioButton
24.21.2.Use StackPanel to Hold RadioButtonsUse StackPanel to Hold RadioButtons
24.21.3.Circled Radio ButtonsCircled Radio Buttons
24.21.4.Color animate based on Radio Button Click eventColor animate based on Radio Button Click event
24.21.5.Radio Button GroupsRadio Button Groups
24.21.6.Set RadioButton to check stateSet RadioButton to check state
24.21.7.Image RadioButtonImage RadioButton
24.21.8.Add checked event listener to RadioButton
24.21.9.Assign value to RadioButton tag