---
title: "CheckBox control in Windows Phone 7 Development"  
description: "If you want to give some options to users and users can select one option or more than one option then we use, CheckBox control are used."  
author: "Anonymous User"  
published: 2012-04-11  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/917/checkbox-control-in-windows-phone-7-development  
category: "windows phone"  
tags: ["windows phone"]  
reading_time: 2 minutes  

---

# CheckBox control in Windows Phone 7 Development

If you want to give some options to users and users can select one option or more than one option then we use, [CheckBox control](https://www.mindstick.com/articles/291/how-should-use-checkbox-control-in-vb-dot-net) are used.\

This article is going to explain how to use CheckBox control in windows 7 phone [application using c#](https://www.mindstick.com/forum/160510/how-to-fetch-data-from-the-database-in-the-dot-net-console-application-using-c-sharp) code. Let’s see a brief demonstration on it.

##### Getting Started:

1. Open [visual studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) and go to **File -> New -> [Project](https://yourviews.mindstick.com/story/1788/things-to-ensure-your-construction-project-is-successful)**.

2. Select [Silverlight](https://www.mindstick.com/blog/54/silverlight-in-asp-dot-net) for Windows Phone option

3. Enter the project name and choose the saving [location](https://www.mindstick.com/news/2574/twitter-conveniently-reveals-a-location-sharing-policy-amid-elonjet-controversy)

4. Click on button **‘Ok’**

Now [drag and drop](https://www.mindstick.com/forum/454/how-to-drag-and-drop-multiple-image-from-one-canvas-to-onther-canvas-in-html5) checkbox control from toolbox which is at top left corner.

![CheckBox control in Windows Phone 7 Development](https://www.mindstick.com/mindstickarticle/91b455ed-6de1-4175-bf4c-cf1391514efd/images/f0a9e43e-deaf-4a50-97e3-a946084ac6c9.png)

Write down the following code to build above layout.

##### Code of ‘MainPage.xaml’:

```
<!--LayoutRoot is the root grid where all page content is placed-->    <Grid x:Name="LayoutRoot" Background="Transparent" Width="480">        <Grid.RowDefinitions>            <RowDefinition Height="Auto"/>            <RowDefinition Height="*"/>        </Grid.RowDefinitions>         <!--TitlePanel contains the name of the application and page title-->        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28" Background="#FF6C1643">            <TextBlock x:Name="ApplicationTitle" Text="My Application" Style="{StaticResource PhoneTextNormalStyle}"/>            <TextBlock x:Name="PageTitle" Text="CheckBox Demo" Margin="0,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Height="90" Width="424" FontSize="48" Foreground="#FFE8E8EB" AllowDrop="False" />        </StackPanel>         <!--ContentPanel - place additional content here-->        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" Background="#FF194533">            <Button Content="Submit" Height="88" HorizontalAlignment="Left" Margin="140,350,0,0" Name="btnSubmit" VerticalAlignment="Top" Width="170" Background="#FF15A7E8" DataContext="{Binding}" AllowDrop="False" UseLayoutRounding="False" VerticalContentAlignment="Center" Click="btnSubmit_Click" />                       <CheckBox Content="Australia" Height="72" HorizontalAlignment="Left" Margin="40,80,0,0" Name="chkAustralia" VerticalAlignment="Top" />            <TextBlock Height="46" HorizontalAlignment="Left" Margin="12,28,0,0" Name="textBlock1" Text="Which country having largest population?" VerticalAlignment="Top" Width="456" FontSize="24" Foreground="#FFEFBA0C" />            <CheckBox Content="England" Height="72" HorizontalAlignment="Left" Margin="40,140,0,0" Name="chkEngland" VerticalAlignment="Top" />            <CheckBox Content="South Africa" Height="72" HorizontalAlignment="Left" Margin="40,198,0,0" Name="chkSAfrica" VerticalAlignment="Top" />            <CheckBox Content="India" Height="72" HorizontalAlignment="Left" Margin="40,254,0,0" Name="chkIndia" VerticalAlignment="Top" />        </Grid> </Grid>
```

Code of MainPage.xaml.cs:

```
using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using Microsoft.Phone.Controls; namespace testPhoneApp{    public partial class MainPage : PhoneApplicationPage    {        // Constructor        public MainPage()        {            InitializeComponent();        }         private void btnSubmit_Click(objectsender, RoutedEventArgse)        {            string checkedItem= null;                       if (Convert.ToBoolean(chkAustralia.IsChecked))                 checkedItem="Australia";             if (Convert.ToBoolean(chkEngland.IsChecked))                 checkedItem+=", England";             if (Convert.ToBoolean(chkSAfrica.IsChecked))                 checkedItem+=", South Africa";             if (Convert.ToBoolean(chkIndia.IsChecked))                 checkedItem+=", India";             if (checkedItem== null)                MessageBox.Show("You have not selected any value!");             else            {                if (checkedItem.Equals(", India"))                    MessageBox.Show("Correct Answer!");                else                    MessageBox.Show("Wrong Answer!");            }         }      }} 
```

Now execute your program and you will see following output.

\

![CheckBox control in Windows Phone 7 Development](https://www.mindstick.com/mindstickarticle/91b455ed-6de1-4175-bf4c-cf1391514efd/images/189f6c8d-d06d-49b1-a762-dacfee8ba924.png)

Now select any option and submit to see your result.

![CheckBox control in Windows Phone 7 Development](https://www.mindstick.com/mindstickarticle/91b455ed-6de1-4175-bf4c-cf1391514efd/images/b2824220-bb8e-4582-868a-4ae7aefedc50.png)

This is the complete description on Windows 7 CheckBox Control. I hope you will be enjoying it and I’m very thankful to you for reading this article. If you’ve any suggestion related to this article, please write your feedback in comment section.

\

---

Original Source: https://www.mindstick.com/articles/917/checkbox-control-in-windows-phone-7-development

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
