I am trying to hide the window MainWindow from another window. I thought that the following code would work until I realised that it would just create another instance of MainWindow, and then hide that, and not the original window!
MainWindow MainWindow = new MainWindow();
MainWindow.Hide();
Then I tried to use just MainWindow.Hide() but that doesn’t work. How can I do it?
You need to get the actual instance of the Window you are trying to hide. If (guessing by the name) this is your main window, you could try:
Otherwise, you need some means of getting the specific instance of the Window you wish to hide.