C# 不接受检查 属性

C# did not accepting checked property

try
    {
        DataRowView drv = attDataGrid.SelectedItem as DataRowView;
        att_id = Convert.ToInt32(drv.Row[0].ToString());
        attComboBox.SelectedItem = drv.Row[1].ToString();
        rdata = drv.Row[2].ToString(); ;
        attDetail.Text = drv.Row[4].ToString();
        DateTime sdt = dc.changeDateG(drv.Row[3].ToString());

        if(rdata.Equals("حاضر"))
        {
                attPre.Checked = true;
        }
        else {
                attUp.Checked = true;
        }

        try
        {
            attDate.SelectedDate = sdt;
        }
        catch (FormatException)
        {
            MessageBox.Show(sdt.ToString());
        }
    }
    catch(NullReferenceException)
    {

    }

我正在尝试将我的 attPre 单选按钮设置为选中状态,但 visual studio 将其视为错误知道如何处理此错误吗???

可能是因为你做的是比较而不是赋值

使用这个: attPre.Checked = true;

而不是 attPre.Checked == true;

我已经知道怎么处理了

RadioButton pr = attPre as RadioButton;
                pr.IsChecked = true;