CheckBox Button
A CheckBox button enables the user to select more options from a group of choices, when paired with other CheckBox button controls. When a user clicks on a one CheckBox button, it becomes checked. You can click a CheckBox to select it and click it again to deselect it.
Prerequisites
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 CheckBoxApp 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 CheckBox Button from the tool box and change the name to Boldch and the content to Bold in the Property Window.
Place another CheckBox Button from the tool box and change the name to Italicch and the content to Italic in the Property Window.
Place one more CheckBox button from the tool box and change the name to Underch and the content to Underline in the Property Window.
Next, drag the button from the Tollbox and change the name to Submitbutton.
Step 6: Add the Coding
To add the coding, double click on the Submit button and add the mentioned source code. Add the following Header file:
Add the following code in the appropriate place (Submit Button).
- private async void Submitbutton_Click(object sender, RoutedEventArgs e) {
- string msg = "";
- if (Boldch.IsChecked == true) {
- msg = "Bold";
- }
- if (Italicch.IsChecked == true) {
- msg = msg + " Italic";
- }
- if (Underch.IsChecked == true) {
- msg = msg + " Underline";
- }
- if (msg.Length > 0) {
- var dialog = new MessageDialog(msg + " selected ");
- await dialog.ShowAsync();
- return;
- } else {
- var dialog = new MessageDialog("No one Selected");
- await dialog.ShowAsync();
- return;
- }
- Boldch.IsThreeState = true;
- }
Step 7: Run the Application
Now, we are ready to run our Project. Thus, click the local machine to run the Application.
Output
Conclusion: I hope you understood Radio button control in Universal Windows and how to run it.