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

Check Group of Radiobutton is selected or not

So i have a Group of RadioButtons in a StackPanel, now i want to check if something is selected or not.

            var programme = programm_wahl.Children.OfType<RadioButton>().FirstOrDefault(r => r.IsChecked.HasValue && r.IsChecked.Value);

        if (programme.IsChecked == true ) {..}

It is throwing me a error that programme is null i tried also programme.IsChecked != null && programme.IsChecked == true both ways not working.

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 :

The error is shown because the programme variable is returning a null value.

Meaning the object .IsChecked is not available.

Try this:

if (programme != null && programme.IsChecked == true) {...}
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