WindowsAppSDK
WindowsAppSDK copied to clipboard
When hiding titlebar a few white pixels still show on top
Describe the bug
When hiding the titlebar using OverlappedPresenter.SetBorderAndTitleBar(true, false)
a few pixels of white titlebar still shows.
Steps to reproduce the bug
- Create a new WinUI app.
- in app.xaml root tag, set
RequestedTheme="Dark"
- in MainWindow.xaml.cs constructor add this code to hide the titlebar
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
Microsoft.UI.WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
Microsoft.UI.Windowing.AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
var presenter = appWindow.Presenter as Microsoft.UI.Windowing.OverlappedPresenter;
presenter.SetBorderAndTitleBar(true, false);
Run the app, and observe the white color on top of the window.
Expected behavior
Entire window is black
Screenshots
NuGet package version
1.1.3
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 21H2 (22000)
IDE
Visual Studio 2022-preview
Additional context
First reported in WinUIEx: https://github.com/dotMorten/WinUIEx/issues/67
@mevey can you take a look?
cc: @btueffers
pong @rkarman
I've successfully repro-ed this bug :( and filed it task.ms/40617153
Hi @dotMorten, what is the intended goal of hiding the title bar? To draw your own? To have a PIP experience? To have a window that is not movable or resizable perhaps? This is helpful as we try to figure out how to solve this problem.
@mevey I'd ask the Windows App SDK team who added that API :-) But a few things come to mind, like splash screens or more custom drawn windows.
Perhaps @ArchieCoder can add details, since he originally logged this bug in WinUIEx
Here is my original issue in WinUIEx: https://github.com/dotMorten/WinUIEx/issues/67
Someone has the workaround: https://github.com/dotMorten/WinUIEx/issues/67#issuecomment-1206649424
@ArchieCoder thanks but I think they are looking for the ‘why’ you were doing this to justify fixing their API
The original goal was to hide the color of the title bar because it didn't find the rest of the app. If the title bar color can be changed, this is then a non-issue anymore.