#356 – RadioButton Basics

RadioButton controls allow a user to select one item from a number of different choices.

When the user clicks on one of the choices, it’s marked with a blue circle and the other choices are cleared.

The behavior is that only one of the RadioButton controls can be active at any given time.

The XAML for this behavior is straightforward.

    <StackPanel HorizontalAlignment="Center" Margin="15">
        <RadioButton Content="Boxers"/>
        <RadioButton Content="Briefs"/>
        <RadioButton Content="Regimental"/>
    </StackPanel>

WPF will automatically generate the behavior that enforces only one of the RadioButton controls being selected at any given time–when they are all children of a common parent control.

If we add a second StackPanel control with two more RadioButtons, we then get two separate groups of choices.

Advertisement

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

3 Responses to #356 – RadioButton Basics

  1. Pingback: Dew Drop – August 3, 2011 | Alvin Ashcraft's Morning Dew

  2. Pingback: #855 – RadioButtons Are Grouped Based on their Container | 2,000 Things You Should Know About WPF

  3. Pingback: #904 – Placing RadioButtons in a TabControl | 2,000 Things You Should Know About WPF

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: