#856 – Placing RadioButtons in a GroupBox

When including a group of RadioButton controls in your application, it’s common to put them in a GroupBox.  This makes the grouping visible to a customer.

A related group of RadioButtons are normally placed in a panel control, to allow the grouping logic to work correctly.  (Only one RadioButton at a time is selected within the group).  Because a GroupBox is a ContentControl, rather than a Panel, you’ll want to place a panel within the GroupBox and then place the related RadioButtons within the panel.

        <GroupBox Header="Gender">
            <StackPanel Margin="10">
                <RadioButton Content="Male"/>
                <RadioButton Content="Female"/>
            </StackPanel>
        </GroupBox>

        <GroupBox Header="Height">
            <StackPanel Margin="10">
                <RadioButton Content="Tall"/>
                <RadioButton Content="Short"/>
            </StackPanel>
        </GroupBox>

856-001