I'm working on a small wpf project using c#. I have 2 windows. When I go from one window to the next, i need to have some items preselected on the 2nd window. I have a checkbox that I need to set the value based on information that I pull from the registry. On the 1st window, i have a reference to the 2nd window. How can I set the checkbox to checked so that when the other window opens it's already checked?
 private void btnGoToNextWindow_Click(object sender, RoutedEventArgs e)
    {
            Window2 w2 = new Window2();
            //This doesn't work             
            w2.Checked = true;
            w2.Show();
            this.Close();
     }
                You can use the IsChecked property.
I hope this helps. Damian
Using this:
        Window2 w2 = new Window2();
        //This doesn't work             
        w2.Checked = true;
You're setting the Checked property of the window not the control. It should be somehting like this:
        Window2 w2 = new Window2();        
        w2.MyCheckBox.IsChecked = true;
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With