Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I know this topic has been discussed many times, but I still cannot get it work. I have 3 RadioButtons that are put in a StackPanel; I am trying to bind their IsChecked to some variable in View Model. Here is what I did:

in XAML file in View:
XML
 <RadioButton Name="rbExpReview"
              IsChecked="{Binding Path=rbExpReviewIsChecked, Mode=TwoWay}"
              Foreground="White">
                   <RadioButton.Content>
                       <Label Content="Experiment Review"
                              HorizontalContentAlignment="Center"
                              VerticalContentAlignment="Center" />
                   </RadioButton.Content>
</RadioButton>


In View Model, I have declared a variable:
C#
_rbExpReviewIsChecked = true;

and the property that responds to IsChecked of the RadioButton:
C#
public bool rbExpReviewIsChecked
       {
           get
           {
               return _rbExpReviewIsChecked;
           }
           set
           {

               _rbExpReviewIsChecked = value;
               OnPropertyChanged("rbExpReviewIsChecked");
           }
       }

However, when I check and uncheck the button, there is no response in the View Model code (break point is not hit.) So I am wondering what is the problem with my binding? Or anything else? I am new to XAML, so any pointer is appreciated. Nick
Posted
Comments
Jan Mikeska 2-Nov-12 11:12am    
Did you try to put a break point in XAML on the line 'IsChecked="{Binding Path=rbExpReviewIsChecked, Mode=TwoWay}'? If the XAML break point is hit expand the locals window and look for BindingState/FinalSource. Check if you can see the property you are trying to bind to.
Lance Contreras 6-Nov-13 2:03am    
I'm also having the same problem. After few hours of googling it, I found out that it's a known bug on the radio button. I found some suggestions of creating a list box and style it like a radio button. However it won't work in my case because I need the GroupName property since I'm using each of my buttons in a data template so i need to bind the group name.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900