Problem when closing a window programmatically

Perhaps my understanding isn’t correct, but after reading the Window section in the docs I would expect calling the window.Close() method should result in the following.

  • If WindowCloseAction is None
    • Window stays open, Closing and Closed events are not fired
  • If WindowCloseAction is Hide
    • Windows hides, Closing and Closed events are not fired
  • If WindowCloseAction is Disposed
    • Windows is disposed, Closing and Closed events are fired

But this isn’t quite what is happening. I have tried this on Windows in Visual Studio and MacOS (intel) in Rider with the following results.

  • When calling windowClose():
    • If WindowCloseAction is None
      • Works as expected
    • If WindowCloseAction is Hide
      • Closing event is fired, but otherwise works as expected
    • If WindowCloseAction is Disposed
      • Window hides but is not disposed
      • Closed event is not fired but Closing event is fired
  • When Clicking on close box in corner instead of calling Close()
    • On Windows: Closing event is not fired, though Closed is fired and window is disposed
    • On MacOS: Works as expected, Closing and Closed are fired and window is disposed

Thank you for your message. I will test the behavior of the Close method and let you know the results as soon as possible.

When WindowCloseAction is set to Hide, the Closing event is fired, and this is the expected behavior. This event allows you to perform checks to determine whether the window close operation should be allowed. I will review the documentation and add some notes there.

I confirm that the window is not disposed when Close is called with WindowCloseAction.Dispose on the MSW platform. This is a bug, and we will address it in upcoming builds. Until it is fixed, you can call SendDispose to close and dispose of the window.

When clicking on close box in corner, Closing/Closed events are fired on MSW. There is a Window related demo in Samples/Window Properties. It logs Closing/Closed events. You can check there and see log items when close box in corner is clicked.

Thank you for looking into this. By the way, AlterNET UI is truly amazing!!!