---
title: "RadioButton Control in Windows 7 Phone Development"  
description: "If you want to give few options to users out of which only one of this can be selected, radio buttons are used. Once you define set of radio buttons,"  
author: "Anonymous User"  
published: 2012-04-11  
updated: 2020-05-21  
canonical: https://www.mindstick.com/articles/916/radiobutton-control-in-windows-7-phone-development  
category: "windows phone"  
tags: ["windows phone"]  
reading_time: 2 minutes  

---

# RadioButton Control in Windows 7 Phone Development

If you want to give few options to users out of which only one of this can be selected, radio buttons are used. Once you define set of radio buttons, you can bind them together using **‘GroupName’** property.\

This article is going to explain how to use [RadioButton](https://www.mindstick.com/blog/233/get-checked-radiobutton-using-javascript) 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.

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**.

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) radio [button control](https://www.mindstick.com/articles/290/button-control-in-vb-dot-net) from toolbox which is at top left corner.

![RadioButton Control in Windows 7 Phone Development](https://www.mindstick.com/mindstickarticle/a6d78097-46a3-4392-856e-640ce106b959/images/8f934cd3-0d2a-442c-a399-e35a3bac8724.png)

Write down the following code to build the 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="RadioButton 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" />            <RadioButton Content="Australia" Height="72" Margin="58,74,205,0" Name="rbAustralia" VerticalAlignment="Top" GroupName="gbtnFavourit" BorderBrush="#BF22DE4D" />            <RadioButton Content="England" Height="72" HorizontalAlignment="Left" Margin="58,152,0,0" Name="rbEngland" VerticalAlignment="Top" GroupName="gbtnFavourit" />            <RadioButton Content="India" Height="72" HorizontalAlignment="Left" Margin="58,230,0,0" Name="rbIndia" VerticalAlignment="Top" GroupName="gbtnFavourit" />        </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)        {            if (Convert.ToBoolean(rbAustralia.IsChecked))            {                MessageBox.Show("You have selected team Australia!");            }            else if (Convert.ToBoolean(rbEngland.IsChecked))            {                MessageBox.Show("You have selected team England!");            }            else if (Convert.ToBoolean(rbIndia.IsChecked))            {                MessageBox.Show("You have selected team India!");            }            else            {                MessageBox.Show("You have not selected any item!");            }                   }               }}
```

Now execute your program and you will see following output.

\

![RadioButton Control in Windows 7 Phone Development](https://www.mindstick.com/mindstickarticle/a6d78097-46a3-4392-856e-640ce106b959/images/48220b18-f0e5-4b77-bc07-eda5b750f93d.png)

Now select any option from above list and click on button **‘Submit’**.

![RadioButton Control in Windows 7 Phone Development](https://www.mindstick.com/mindstickarticle/a6d78097-46a3-4392-856e-640ce106b959/images/ef1b787e-713d-4edb-be3e-607b515ea02a.png)

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