Table of Contents

Problem:

It is very simple issue ,but we can't to make checked event fire on same radiobutton which is already selected. Actually this question is raised at Msdn WindowsPhone Development Forums .
 
  Requirement:
         Page having two radio buttons for :1)Phone 2)Email 
        

          So if the user wants to register via phone number then he needs to turn on his cellular data connection...when he/she comes back to the app the radionbutton will be already selected, but I want the user to select the same radiobutton again....so that the mobile data connection takes effect....

Solution:

There is two ways for solving this issue:

1)kept your radio button IsChecked=false; at OnNaviagatedTo event ,so that when user return back to page then automatically your radio button will be unchecked so that he can again able to check the radiobutton

protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            PhoneRadioBtn.IsChecked = false;
        }
 private void PhoneRadio_check(object sender, RoutedEventArgs e)
         {
             Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-cellular:"));
         }

2)Using Tap event of RadioButton:
 We have Tap event for radio button,However it will be fire after checked event so that we can check on tap event whether RadioButton is already selected or not,If it is already selected makes once PhoneRadio.IsChecked=false; and set again PhoneRadio.IsChecked=true;

Note: PhoneRadio.IsChecked=true;  when you set this PhoneRadio Checked Event will be fire automatically.

Step1:

 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <RadioButton Tap="PhoneRadio_Tap" Grid.Row="0" Checked="PhonetRadio_check" 
Content="Phone"  Name="PhonetRadio" GroupName="MyRadioButtons"/>
            <RadioButton Grid.Row="1" Content="Email" Name="EmailRadio" 
GroupName="MyRadioButtons" Margin="0,0,0,67"/>
</Grid>

Note: Set GroupName property for both the radiobuttons. So when you select one radiobutton, other radiobutton will get unselected.

Step2:

PhonetRadio_check  Event:

private void PhonetRadio_check(object sender, RoutedEventArgs e)
         {
             Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-cellular:"));
         }

Step3:

PhoneRadio_Tap Event

 private void PhoneRadio_Tap(object sender, System.Windows.Input.GestureEventArgs e)
         {
             if (PhonetRadio.IsChecked == true)
             {
                 PhonetRadio.IsChecked = false;
                 PhonetRadio.IsChecked = true;
             }
         }

Reference:


Msdn Forum: Link

And please find my more MSDN Code samples

Author:SubramanyamRaju
Blog:http://bsubramanyamraju.blogspot.in/