none
Using ToggleButtons as Radio Buttons RRS feed

  • Question

  • I have created a style which creates togglebuttons as RadioButtons.  It all pretty much works the way I want except the uncheck toggle works on checked items unlike the radio button operation where only selecting another item in group unchecks it.  I am searching for a way to modify the style to achieve this correction of operation.

       <Style TargetType="RadioButton" x:Key="RadioStyle2">
            <Setter Property="Background" Value="{ThemeResource ButtonBackground}" />
            <Setter Property="Foreground" Value="{ThemeResource ButtonForeground}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="RadioButton">
                        <ToggleButton HorizontalAlignment="Left" VerticalAlignment="Stretch" BorderThickness="1,1,5,5" BorderBrush="{StaticResource BorderBrush}" Width="{Binding Width, RelativeSource={RelativeSource TemplatedParent}}" IsChecked="{Binding IsChecked, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                              Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" FontFamily="{Binding FontFamily, RelativeSource= {RelativeSource templatedParent}}" Foreground="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"
                              Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    


    Martin Autry

    Monday, September 11, 2017 8:25 PM

Answers

  • @Martin Autry

    Any updates?

    Have you solved your problem?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 13, 2017 1:11 AM
    Moderator

All replies