microsoft / microsoft/microsoft-ui-xaml
Exception occurs when setting ExtendsContentIntoTitleBar to true
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
When setting ExtendsContentIntoTitleBar to true on a window that is not the main window, and enabling native debugging, an exception is thrown and the app crashes.
This issue does not occur in version 1.6, but it started happening from version 1.7.
WinUI3 with C#
### Steps to reproduce the bug
1. Right-click the project name and select "Properties", then turn "Enable native code debugging" to ON.

2. Appxaml.cs
```
namespace MyCrashSample
{
public partial class App : Application
{
public App()
{
this.InitializeComponent();
}
protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
SplashScreen splash_screen = new();
splash_screen.Activate();
await Task.Delay( 100 );
this.m_window = new MainWindow();
this.m_window.Activate();
splash_screen?.Close();
}
private Window? m_window;
}
}
```
3. Create a SplashWindow separately from the main window. The code is as follows:
Set ExtendsContentIntoTitleBar to true.
```
namespace MyCrashSample
{
public sealed partial class SplashScreen : Window
{
public SplashScreen()
{
this.InitializeComponent();
this.ExtendsContentIntoTitleBar = true;
}
}
}
```
4. Run the app. An exception is thrown immediately on launch. If it doesn't happen on the first try, it will occur after a few attempts.
> Exception thrown at 0x00007FFF0313933A (in AtoDeKesu.exe): Microsoft C++ exception: winrt::hresult_error (memory location 0x000000139FF9DBF0).
### Expected behavior
_No response_
### Screenshots
_No response_
### NuGet package version
Windows App SDK 1.7.0: 1.7.250310001
### Packaging type
Packaged (MSIX)
### Windows version
Windows 11 version 24H2
### IDE
Visual Studio 2022
Contributor guide
Research direction
Start with the Appxaml.cs launch sequence and the SplashScreen constructor shown in the report. Reproduce with native code debugging enabled on Windows App SDK 1.7, then compare behavior with version 1.6. Done means launching the packaged sample with ExtendsContentIntoTitleBar enabled on the secondary window without the reported exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100