RadioButton
RadioButton enables the user to select a single option from a group of the choices, when paired with other RadioButton controls. When a user clicks on one RadioButton, it becomes checked and all other RadioButtons with the same group becomes unchecked.
Prerequisites
- Visual Studio 2015
Now let's get started with the following steps:
Step 1 : Create Windows Universal Project
Open Visual Studio 2015 and click File -> New -> Project option for New Universal App.

Step 2: Giving the Project Name
New Project Window will open, where you can select an Installed -> Template -> Visual C# -> Windows -> Universal and select a Blank App (Universal Windows).
Type Project Name RadioButtonApp and click OK button.

Step 3: Setting the platform Versions
Here, we choose the Target Version and Minimum Version for our Universal Windows Application and click OK button.

Step 4: Choose Designer Window
Now, we go to the Solution Explorer and select MainPage.xaml
Step 5 : Designing the App
Drag the RadioButton from the tool box and change the Name to Male, Content to Male and GroupName to Gender in the Property Window.

Place another RadioButton from the tool box and the Name to Female, Content to Female and GroupName to Gender in the Property Window.

Next, drag the button from the Toolbox and change the name to Submit button

Step 6: Add the Coding
To add the coding, double click on the Submit button and add the mentioned source code.
Add the Mentioned Header file

- using Windows.UI.Popups;

- Private async void Submitbutton_Click(object sender, RoutedEventArgs e) {
- if (RadioMale.IsChecked == true) {
- var dialog = new MessageDialog("You are Selected Male");
- await dialog.ShowAsync();
- return;
- } else {
- var dialog = new MessageDialog("You are Selected Female");
- await dialog.ShowAsync();
- return;
- }
- }
Now, we are ready to run our project. Thus, click the local machine for running the Application.

Output

Conclusion: I hope you understood RadioButton control in Universal Window and how to run it.

Anbu ManiPosted Aug 18, 2016, 3:25 AM
Nice
Vignesh ManiPosted Aug 17, 2016, 7:54 AM
Good one
SubashPosted Aug 17, 2016, 12:37 AM
Very nice Explation