在wpf中播放单选按钮c#

时间:2012-10-23 00:55:35

标签: c# wpf

hi guyz如果未选中相应的单选按钮,我怎么能将我的文本框readonly设置为true,反之亦然。与datepicker,combobox focusable和ishittestvisible相同的东西,如果相应的按钮也未选中,则等于false,反之亦然......谢谢

我发现在wpf c#中,radiobutton没有checkchange属性。只有在winform ...这就是我要做的事情

    private void rdbtn1_Checked(object sender, RoutedEventArgs e) // <----This must CheckChange
    {
        if (rdbtndatecreated.IsChecked == true)
        {
            textBox1.IsReadOnly = false;
            DatePicker1.Focusable = true;
            DatePicker1.IsHitVisible = true;
        }
        else
        {
            textBox1.IsReadOnly = true;
            DatePicker1.Focusable = false;
            DatePicker1.IsHitVisible = false;
        }
    }

1 个答案:

答案 0 :(得分:1)

您可以单独处理CheckedUnchecked事件。

void rdbtn1_Checked(object sender, RoutedEventArgs e)
{
     textBox1.IsReadOnly = false;
     DatePicker1.Focusable = true;
     DatePicker1.IsHitVisible = true;
}


void rdbtn1_Unchecked(object sender, RoutedEventArgs e)
{    
     textBox1.IsReadOnly = true;
     DatePicker1.Focusable = false;
     DatePicker1.IsHitVisible = false;    
}