RadioButton IsChecked Binding not working

I was trying to bind a group of RadioButtons to a DependencyProperty of type bool, and I notice that when changing the selection of the radio buttons it didn’t change the DependencyProperty. I searched the web for answers and I found only these 2 threads describing the problem.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2052600&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1429712&SiteID=1

Unfortunately there are no good workarounds to this issue and it is not fixed yet in framework 3.5. The only solution that I found is to register to the Checked and UnChecked RoutedEvents of the RadioButton, and updating my data manually when the events are raised.

The Xaml:

    <Grid>

        <RadioButton GroupName=”MyGroup”

             HorizontalAlignment=”Center”

             Content=”Option A”

Checked=”OnOptionAChecked”
Unchecked
=”OnOptionAUnchecked” />

        <RadioButton GroupName=”MyGroup”

             HorizontalAlignment=”Center”

             Content=”Option B” />

    </Grid>

And the code behind:

private void OnOptionAChecked(object sender,
RoutedEventArgs e)

{

    MyProperty = true;

}

private void OnOptionAUnchecked(object sender, RoutedEventArgs e)

{

    MyProperty = false;

}

I hope that a fix will be introduced to framework 3.5.

2 Responses to “RadioButton IsChecked Binding not working”

  1. ReadioButton IsChecked Binding Problem - Conclusions « WPF, .NET & Other stuff Says:

    [...] IsChecked Binding Problem - Conclusions After I posted my previous post on this subject, I done some research on this issue and I found the [...]

  2. RadioButton IsChecked Binding Problem in .NET 3.5 RTM « WPF, .NET & Other stuff Says:

    [...] my first post I described the problem and in second post I proposed and demonstrated a workaround to the [...]

Leave a Reply