How do you tell if a WPF Window is closed?

前端 未结 7 2014
情深已故
情深已故 2020-12-09 07:27

I\'m working on an application that displays some child windows which can either be closed by the user or are automatically closed. While debugging some exceptions that wer

7条回答
  •  不思量自难忘°
    2020-12-09 07:47

    If you derive from the Window class, you can do this:

    public bool IsClosed { get; private set; }
    
    protected override void OnClosed(EventArgs e)
    {
        base.OnClosed(e);
        IsClosed = true;
    }
    

    It has an advantage over registering for the Closed event - no need to un-register the callback.

提交回复
热议问题