-
Notifications
You must be signed in to change notification settings - Fork 803
Description
Describe the bug
In a WinUI 3 XAML-hosted application, when closing an explicitly created child window, it throws exception and causes application crash.
We are creating and activating a WinUI 3 window using a button click handler available in the XAML page, which is hosted over the native application.
In this scenario, should we do any extra handling to close the newly created window properly?
Any help is appreciated.
Steps to reproduce the bug
- Download and build the XAML Island sample application available in the following repo.
https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/Islands - Add the following lines of code inside the WinUI button click handler available in the "MainPage" cpp file.
auto ChildWindow = Microsoft::UI::Xaml::Window();
ChildWindow.Activate();
- Build and run the application.
- Click the WinUI 3 button.
- Close the newly created WinUI 3 window using close icon.
Expected behavior
The window should close without any exception, and the parent app should continue to run as it is.
Screenshots
No response
NuGet package version
Windows App SDK 1.4.3: 1.4.231115000
Packaging type
Unpackaged
Windows version
Windows 10 version 22H2 (19045, 2022 Update)
IDE
Visual Studio 2022
Additional context
The same behavior is found if we create an XAML window using the Blank Window (WinUI 3 in Desktop) template and activate it inside the button click handler.