Resolved Issue closing window

MattNorman

Well-known member
Joined
May 22, 2021
Messages
98
Programming Experience
1-3
I am having some issues closing a window and have no idea why as there is nothing fancy going on.

I create a new instance of my AutoSizeWindow and cache a reference to it.

Update the content control of the window and show it.

The when I try to close it, the close method fires fine but it stays on the screen even when the cached reference is set to null.

C#:
 /// <summary>
/// Displays the dashboard in display mode.
/// </summary>
public void ShowDashboardDisplayMode(object param)
{
    dashDisplayWindow = new AutoSizeWindow();
    dashDisplayWindow.cntMain.Content = new DashboardDisplayModeView();
    dashDisplayWindow.Show();
}

/// <summary>
/// Closes the dahsboard.
/// </summary>
public void CloseDashboard(object param)
{
    if (dashDisplayWindow != null)
    {
        dashDisplayWindow.cntMain.Content = null;
        dashDisplayWindow.Close();
        dashDisplayWindow = null;
    }
}
 
This is now resolved.

Silly mistake on my behalf when caching the reference to the window in the wrong view model.
 
Solution
Back
Top Bottom