I have two Windows (main window & sub window) in WPF Application. In main window I have a button that will minimize main window and sub window will be opened as maximized.
When I am closing the sub window, I need to restore main window.
Can anybody help?
Thanks
Window Show/Hide
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Kirtan PatelRank #292 · 8.6K reputationPosted Feb 25, 2010, 8:43 AM EST
Suppose you have Window1 and Window2 Windows1 is main Windows and Window2 is Sub Windows.
Window1 Button Code
----------------------------
private void button1_Click(object sender, RoutedEventArgs e)
{
Window2 w2 = new Window2(this);
w2.Show();
this.Hide();
}
Window 2 Code
-------------------
public partial class Window2 : Window
{
Window1 referenceWindow;
public Window2()
{
InitializeComponent();
}
// you need To Add Below Overloaded Constructor
public Window2(Window1 FormObject)
{
InitializeComponent();
referenceWindow = FormObject;
}
// In windows Closing event Write this
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
referenceWindow.WindowState = WindowState.Maximized;
referenceWindow.ShowActivated = true;
referenceWindow.Show();
}
}
Van Matiz18 reputationPosted Feb 25, 2010, 6:11 PM EST