[英]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.所以我在 StackPanel 中有一组 RadioButtons,现在我想检查是否选择了某些东西。
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.它给我一个错误,程序是 null 我也试过programme.IsChecked.= null && programme.IsChecked == true
两种方式都不起作用。
The error is shown because the programme
variable is returning a null value.显示错误是因为programme
变量返回 null 值。
Meaning the object .IsChecked
is not available.意味着 object .IsChecked
不可用。
Try this:尝试这个:
if (programme != null && programme.IsChecked == true) {...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.