O'Reilly logo

Windows Presentation Foundation 4.5 Cookbook by Pavel Yosifovich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Selecting options with checkboxes and radio buttons

Checkboxes and radio buttons are some of the most recognizable and useful controls. Checkboxes allow selecting or unselecting options, while radio buttons allow selecting one option out of several. Let's see how to use them in WPF.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create a simple tea choosing application that uses checkboxes and radio buttons to make some tea:

  1. Create a new WPF application named CH04.SelectingOptions.
  2. Open MainWindow.xaml. Replace the Grid with a StackPanel.
  3. Add a GroupBox with some tea type options to the StackPanel, as follows:
    <GroupBox Header="What kind of tea would you like?"> <StackPanel Margin="4" x:Name="_teaTypePanel"> <RadioButton ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required