microsoft / microsoft/microsoft-ui-xaml
Unable to remove thin border anymore from window using DWM_WINDOW_CORNER_PREFERENCE set to DWMWCP_DONOTROUND
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
In previous version of the Windows App SDK, you used to be able to create a top-level window with a TransparentTintBackdrop and the DWM non-client rendering attribute to not use rounded corners on a window. This used to work on Windows App SDK versions 1.5.8 or earlier.
After upgrading to the latest version of the Windows App SDK (1.6.3 as of this writing), this has stopped working, and instead you get a thin border around the window, that I don't know how to remove. I have tried many different things, none of them have worked.

Is there any way to remove this thin border?
### Steps to reproduce the bug
Here is some sample code:
```
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using System;
using Windows.Foundation;
using Windows.Win32.Foundation;
using Windows.Win32.Graphics.Dwm;
using WinUIEx;
using static Windows.Win32.PInvoke;
namespace MyApp;
internal sealed partial class MyWindow : Window
{
public readonly WindowManager Manager;
public MyWindow()
{
// Initialize the window.
InitializeComponent();
SystemBackdrop = new TransparentTintBackdrop();
Manager = WindowManager.Get(this);
Manager.PresenterKind = AppWindowPresenterKind.Overlapped;
Manager.MinWidth = 0;
Manager.MinHeight = 0;
Manager.IsAlwaysOnTop = false;
Manager.IsTitleBarVisible = false;
Manager.IsMaximizable = false;
Manager.IsMinimizable = false;
Manager.IsResizable = false;
var style = WindowStyle.TabStop | WindowStyle.Group | WindowStyle.ClipSiblings;
this.SetWindowStyle(style);
var exstyle = ExtendedWindowStyle.ToolWindow;
this.SetExtendedWindowStyle(exstyle);
// Disable rounded corners. This also has the effect of removing small thin border created
// around the window. The order in which this function is called is important.
unsafe
{
var hwnd = new HWND(WinRT.Interop.WindowNative.GetWindowHandle(this));
uint pref = (uint)DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DONOTROUND;
DwmSetWindowAttribute(hwnd, DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE, &pref, sizeof(uint));
}
// Show the window.
this.Show();
}
}
```
### Expected behavior
It should be possible to create a window with no border, shadow effects, or anything else.
### Screenshots

### NuGet package version
Windows App SDK 1.6.3: 1.6.241114003
### Packaging type
Unpackaged
### Windows version
Windows 11 version 22H2 (22621, 2022 Update)
### IDE
Visual Studio 2022
### Additional context
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the sample on Windows 11 22H2 with Windows App SDK 1.6.3, then compare the behavior with version 1.5.8. Inspect the DWM_WINDOW_CORNER_PREFERENCE call and its ordering relative to Show(), using the provided MyWindow constructor as the entry point. Done means a top-level window can use TransparentTintBackdrop with no thin border or unwanted shadow effects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100