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 check
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;
I'd say that you should move towards pushing the view model into the view via IoC or some other fashion. Tie the value to a property and let the framework make your life easier via binding, instead of having to hard code values all over the place.
http://msdn.microsoft.com/en-us/library/ms752347.aspx
You can use the IsChecked property.
I hope this helps. Damian