0
votes

I would like to have a group of radio buttons which the circles for un-selected and selected mode are changed to circle icons that I designed.

It that possible to do that in WPF? Thanks in advance

2

2 Answers

3
votes

Create a style and override the default template for RadioButtons. Something like this:

<Window.Resources>
    <Style TargetType="RadioButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RadioButton}">
                    <BulletDecorator Background="Transparent">
                        <BulletDecorator.Bullet>
                            <Grid Width="13" Height="13">
                                <Ellipse x:Name="Border" StrokeThickness="2">
                                    <Ellipse.Stroke>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="Green" Offset="0" />
                                            <GradientStop Color="Pink" Offset="1" />
                                        </LinearGradientBrush>
                                    </Ellipse.Stroke>
                                    <Ellipse.Fill>
                                        <LinearGradientBrush StartPoint="0,0"
                                   EndPoint="0,1">
                                            <LinearGradientBrush.GradientStops>
                                                <GradientStopCollection>
                                                    <GradientStop Color="Orange" />
                                                    <GradientStop Color="Red"
                                  Offset="1.0" />
                                                </GradientStopCollection>
                                            </LinearGradientBrush.GradientStops>
                                        </LinearGradientBrush>
                                    </Ellipse.Fill>
                                </Ellipse>
                                <Ellipse x:Name="CheckMark"
                   Margin="4"
                   Visibility="Collapsed">
                                    <Ellipse.Fill>
                                        <SolidColorBrush Color="Purple" />
                                    </Ellipse.Fill>
                                </Ellipse>
                            </Grid>
                        </BulletDecorator.Bullet>
                      <ContentPresenter Margin="4,0,0,0"
                        VerticalAlignment="Center"
                        HorizontalAlignment="Left"
                        RecognizesAccessKey="True" />
                    </BulletDecorator>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
1
votes

Yes, of course, it is possible. You can override default ControlTemplate and create style for your own radiobutton. Here is an example, you can also use Style Snooper to see the WPF built-in radio button style (a big piece of XAML code:) )