1
我定義了一些ItemsControl並將其添加到ItemsControl.Items中一個12個RadioButtons。 其中一個RadioButton被選中。 我想找到Checked RadioButton的上下文。如何使用Linq在ItemsControl.Items中找到正確的項目
,我寫的(而不能很好地工作)的代碼
string str = (from t1 in itemsControl.Items.OfType<RadioButton>()
where t1.IsChecked == true
select t1.Content).ToString();
什麼是我的錯? 我如何以其他方式做到這一點(我不想用於/ foreach循環)
謝謝。