#904 – Placing RadioButtons in a TabControl

If you like, you can place a group of RadioButton controls on each tab of a TabControl.  Because each tab of the TabControl can contain only a single element, you need to place the individual RadioButtons within a container (e.g. a StackPanel) which is then placed within the TabItem.

Because RadioButton selection is automatically managed, for all RadioButtons within the same container, this scheme ensures that only one RadioButton on each tab can be selected.

Below is an example.

    <TabControl Margin="10">
        <TabItem Header="Breakfast">
            <StackPanel>
                <RadioButton Content="Eggs"/>
                <RadioButton Content="Cereal"/>
                <RadioButton Content="Spam"/>
            </StackPanel>
        </TabItem>
        <TabItem Header="Lunch">
            <StackPanel>
                <RadioButton Content="Ham Sandwich"/>
                <RadioButton Content="Soup"/>
                <RadioButton Content="Wimpy Burger"/>
            </StackPanel>
        </TabItem>
        <TabItem Header="Dinner">
            <StackPanel>
                <RadioButton Content="Steak"/>
                <RadioButton Content="Fish"/>
                <RadioButton Content="Haggis"/>
            </StackPanel>
        </TabItem>
    </TabControl>

904-001

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #904 – Placing RadioButtons in a TabControl

  1. Patrick says:

    Brilliant stuff! Extremely useful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: