microsoft-ui-xaml: ExtendsContentIntoTitleBar and wrong window top border color

Describe the bug

In WinUI 3 project, the top border of window is drawn black when ExtendsContentIntoTitleBar is true.

Steps to reproduce the bug

  1. Create ‘Blank App, Packaged (with WinUI 3 in Desktop)’
  2. Set ExtendsContentIntoTitleBar to true in the MainWindow constructor

Expected behavior

No response

Screenshots

winui

NuGet package version

WinUI 3 - Windows App SDK 1.0

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 17 (3 by maintainers)

Most upvoted comments

A workaround:

using System;
using System.Runtime.InteropServices;
using WinRT.Interop;

public sealed partial class MainWindow : Window {

  [StructLayout(LayoutKind.Sequential)]
  struct MARGINS {
    public int cxLeftWidth;
    public int cxRightWidth;
    public int cyTopHeight;
    public int cyBottomHeight;
  }

  [DllImport("dwmapi")]
  static extern IntPtr DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);

  public MainWindow() {
    var handle = WindowNative.GetWindowHandle(this);
    var margins = new MARGINS { cxLeftWidth = 0, cxRightWidth = 0, cyBottomHeight = 0, cyTopHeight = 2 };
    Activated +=
      (object sender, WindowActivatedEventArgs args) => DwmExtendFrameIntoClientArea(handle, ref margins);
    ExtendsContentIntoTitleBar = true;
  }

  // ...

}

It is in the pipeline of the team and should be done in a future release. The developers will update the high contrast bug if it is fixed internally and with the tag of build it will be coming in .

This bug is still present in the 1.1 version.