Check if opened window has been closed

c#, sql-server, wpf

Solution

Why not simply add a handler to the Closing or Closed event:

private void ShowChildWindow()
{
    Window childWindow = new ChildWindow();
    childWindow.Closed += ChildWindowClosed;
    childWindow.Show();
}

private void ChildWindowClosed(object sender, EventArgs e)
{
    ((Window)sender).Closed -= ChildWindowClosed;
    RepeaterRefresh();
}

Problem

I have a main window, which is the application start up window. In that window, there is a `Repeater` control binded to a `SQL Database`, and a button to open a new window. The new window has a method that inserts data into the `SQL Database` that the first windows' `Repeater` control reads from. The repeater has a `RepeaterRefresh()` method that forces it to rebind to the `SQL Database`, revealing anything added. How would I be able to bind the `Close()` event of the second window to the `RepeaterRefresh()` method, so the data is automatically shown on the repeater. I have read this, this and this, but I still feel that my question doesn't relate.

Original source

Related problems