If MainWindow
is your startup window, you can get it using Application.Current.MainWindow
.
Since MainWindow will return instance of Window, you need to typecast it back to MainWindow:
MainWindow window = (MainWindow)Application.Current.MainWindow;