简体   繁体   中英

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.

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) {...}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM