RadioButton control in Silverlight

Introduction: RadioButton control is used to select single option among two or more options of a group.

We take a silverlight application and then we take four RaddioButton on design surface. The XAML code will be look like below

<Grid x:Name="LayoutRoot" Background="White">
        <RadioButton Content="RadioButton" Height="16" HorizontalAlignment="Left" Margin="10,10,0,0" Name="RadioButton1" VerticalAlignment="Top" />
        <RadioButton Content="RadioButton" Height="16" HorizontalAlignment="Left" Margin="10,36,0,0" Name="RadioButton2" VerticalAlignment="Top" />
        <RadioButton Content="RadioButton" Height="16" HorizontalAlignment="Left" Margin="10,62,0,0" Name="RadioButton3" VerticalAlignment="Top" />
        <RadioButton Content="RadioButton" Height="16" HorizontalAlignment="Left" Margin="10,88,0,0" Name="RadioButton4" VerticalAlignment="Top" />
</
Grid>

 When, We run the application, We can select only one option among four because all the four option will come in one group. We can select one option from one group. The output window will look like below figure

Radio Button

Figure-1

Now, We categories these four options into two group as group a and group b. The XAML code will look like below

<Grid x:Name="LayoutRoot" Background="White">
             <RadioButton Content="RadioButton" Height="16" HorizontalAlignment="Left" Margin="10,10,0,0" Name="RadioButton1" VerticalAlignment="Top" GroupName="a" />                   <RadioButton Content="RadioButton" Height="16" HorizontalAlignment="Left" Margin="10,36,0,0" Name="RadioButton2" VerticalAlignment="Top" GroupName="a" />                         <RadioButton Content="RadioButton" Height="16" HorizontalAlignment="Left" Margin="10,62,0,0" Name="RadioButton3" VerticalAlignment="Top" GroupName="b" />                     <RadioButton Content="RadioButton" Height="16" HorizontalAlignment="Left" Margin="10,88,0,0" Name="RadioButton4" VerticalAlignment="Top" GroupName="b" />
</
Grid>

Then, we run our application. Now there are two group and we can select one option from one group. Like below figure

 Radio Button

Figure-2