Question : How control a window from another one in wpf application?

I added a window (name=Window1) to my Wpf application. Inside Window1 I droped a Button component (Name=Button1).  I could open Window1 by  clicking  on a button which I have inside my  MainWindow (MainButton).
1) When I open my application I get by default MainWindow opened.
2) I press MainButton and I get Window1 (Without closing MainWindow)
3) When I click button1(inside Window1)   I wich be able to change the background color of Mainbutton (inside MainWindow ) to red. I can't  acomplish this simple task! I even canot have acces to  mainwindow from withen window1.
Please help !

Answer : How control a window from another one in wpf application?

Oh forgive me about access modifiers , don't need to set them in wpf.
but you can change your button properties as below:
suppose the window you want to change button inside it is MainWindow.
you can looking for it in open windows like this:
and change every control properties you want:

System.Windows.Window m = new System.Windows.Window();
           foreach (System.Windows.Window w in Application.Current.Windows)
           {
               if (w.Name == "MainWindow")
               {
                   m = w;
                   break;
               }

           }

           (m as MainWindow).textBox1.Text = "test";
Random Solutions  
 
programming4us programming4us