Kenshi Hemura
Kenshi Hemura

Reputation: 135

Playing with Radio button in wpf c#

hi guyz how can i set my textbox readonly to true if the appropriate radiobutton is unchecked and vice versa also. same thing with datepicker,combobox focusable and ishittestvisible is equal to false when the appropriate button also is unchecked and vice versa... thanks

i found out that in wpf c#.. the radiobutton doesnt have checkedchange property. only in winform... here's what im goin to do

    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;
        }
    }

Upvotes: 0

Views: 509

Answers (1)

keyboardP
keyboardP

Reputation: 69372

You can handle the Checked and Unchecked events separately.

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;    
}

Upvotes: 1

Related Questions