Being an old VB coder, I fondly remember this control as the Option Button, but these days it’s been renamed to the RadioButton. They are used to present the user with a set of mutually exclusive options.
Adding them is simple, just use the <RadioButton> tag. For the button you wish to be the default (if any) you add the IsChecked=”true” flag.
WPF adds a huge improvement over it’s predecessor. No longer are you forced to use a container control to group your radio buttons. Instead, WPF adds a GroupName property. Take a look at this example:
<StackPanel>
<RadioButton GroupName=“One“ IsChecked=“True“>Option 1</RadioButton>
<RadioButton GroupName=“One“ IsChecked=“False“>Option 2</RadioButton>
<RadioButton GroupName=“Two“ IsChecked=“False“>Option 3</RadioButton>
<RadioButton GroupName=“Two“ IsChecked=“True“>Option 4</RadioButton>
</StackPanel>
Note the GroupName, for the first two items, I’ve set it to One, on the second two it’s Two. This means you can change Option 1 and Option 2 without affection Options 3 or 4. Go ahead and run the app, click on the options a bit and watch what happens.
In my example, I only entered two items for each, the actual number you can do is limited only by the space you have available on your Window.
The C# code for checking the value is identical to yesterday’s code for the CheckBox so I won’t reiterate it, all you have to do is look at the IsChecked property.
One last point, event though adding containers are not required to separate the option groups, it’s important to provide some sort of visual indicator so the user knows which groups do what.


June 19, 2008 at 10:06 am
In your example… how do i know wich one is selected by the user?
Greetings
June 19, 2008 at 10:10 am
What i meant is… i have to “iterate” or “look” on each one of the radio Buttons… how if you didn’t use the Name property… can i use the groupName and get the radioButtons inside the group???
Thanks
May 15, 2009 at 11:23 pm
Fantastic little tutorial. Quick, helpful, clear. I’ve found lots of useful stuff on this site. Thanks
November 7, 2009 at 3:05 pm
Excellent article. Here is something just to complete the loop.
Given this XAML:
///
Option 1
Option 2
Option 3
/// and this code behind (C#)
bool? testWhichRadioButtonClickedBool = null;
testWhichRadioButtonClickedBool = RadioBtn1.IsChecked;
if (testWhichRadioButtonClickedBool != null)
{
if (testWhichRadioButtonClickedBool != false)
{
//do first procedure here
}
}
testWhichRadioButtonClickedBool = RadioBtn2.IsChecked;
if (testWhichRadioButtonClickedBool != null)
{
if (testWhichRadioButtonClickedBool != false)
{
//do second procedure here
}
}
testWhichRadioButtonClickedBool = RadioBtn3.IsChecked;
if (testWhichRadioButtonClickedBool != null)
{
if (testWhichRadioButtonClickedBool != false)
{
//do third procedure here
}
}
//only one of these three if statements is true at any time
May 7, 2013 at 3:24 pm
com provides information on Fishing, Fly Fishing, Fishing Boats, Deep Sea Fishing and.
Pay close attention to the mayflies, midges, and stoneflies in the
area and try to match your flies to the size and type fish are biting on.
But here’s my top 5 to consider with choices for both types of water included:.
May 8, 2013 at 2:36 am
Where there was less effort wasted, so is less time wasted.
It is also possible for users to conduct charitable and humanitarian
works online. – Its also a great idea to insert a bio
about you, people do want to know who you are and what you like, remember this is social networking.
May 8, 2013 at 11:22 pm
This is more important than ever in a world
where there are dozens of different audio formats.
They also apparently believe that their customers who like a particular song they hear on
the radio, are likely to purchase that song, which could add to downloads from i – Tunes.
Whats more is that 2G phones can come in a tinier and slimmer package, even its batteries.
May 12, 2013 at 6:10 pm
If, at the end of this time period, the score is
tied, there are two options the officials can take.
By obtaining increasingly more favour using their company
people in your social settings, the more handle you will need to acquire what you would like, and thru
The particular Coalition Game you have just about the most effective tips for hypnotherapy that gives you the
talent to ensure that you influence other folks. This classic game integrates all-out entertainment with vocabulary enhancement in one amazing game.
May 13, 2013 at 5:16 pm
The Squeezbox Boom radio from Logitech is not just an Internet radio.
“It’s hard to believe, ” says Randy Gilbert, host of “The Inside Success Secrets Radio Show”-an Internet radio broadcast which has been “airing”
for several years. They explained how banners are
bought via a network so they get low CPMs, an obscene amount of views and a good click-through ratio.
May 14, 2013 at 7:35 am
The developers are saying that Defiance is a pixel perfect shooter,
so if you aim at your target’s head it WILL be a headshot instead of the invisible dice rolling a 5 and telling you that you somehow missed. It should come as no surprise that i – Tunes is loaded full of pirate apps for i – Phone, i – Pod Touch, and i – Pad. Preparing to apply to the dozens of other game development companies for video game jobs will enable you to expand and diversify your list of possible employers, and your chances of getting hired will increase tremendously.
May 18, 2013 at 7:15 pm
Dominion: Intrigue is a standalone expansion for the award-winning Dominion card game that
shook the gaming world in 2008. Caution: when a hole is made in a can, there may be metallic edges that can cut one’s mouth. This classic game integrates all-out entertainment with vocabulary enhancement in one amazing game.
May 25, 2013 at 8:26 pm
Though the levels look really simple, they are actually quite challenging.
Just last year Apple sold more than one hundred million i – Phone and i – Pad apps.
Most video game testers reported that their salary falls between $15,000 and $55, 000 in a year.