Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add an CheckedChanged or SelectedValueChaged event in a RadioButton

Do you have any example or reference on how am I going to add an event to a new RadioButton object. So basically I created an RadioButton object in my ViewModel with properties.

var grid = new Grid();
grid.Children.Add(new RadioButton() 
{ 
   IsChecked = question.Answer != null && question.Answer.Value == qa.Value,
   IsEnabled = !this.IsReadOnly,
   GroupName = $"question-{question.OrderNum}",
}, 0, 0);

So with that I want to add the event of CheckedChaged or SelectedValueChanged so that I can save the selected value of the user from those RadioButton.

Thank you

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

var grid = new Grid();

var radio = new RadioButton() 
{ 
   IsChecked = question.Answer != null && question.Answer.Value == qa.Value,
   IsEnabled = !this.IsReadOnly,
   GroupName = $"question-{question.OrderNum}",
};

radio.CheckedChanged += myEventHandler;

grid.Children.Add(radio,0,0);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading