microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

ExtendsContentIntoTitleBar and wrong window top border color

Open pavel-zhukov opened this issue 3 years ago • 6 comments

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
  • [x] Win32

Device form factor

Desktop

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

pavel-zhukov avatar Mar 30 '22 06:03 pavel-zhukov

Any progress on this issue?

bongvisu avatar May 04 '22 02:05 bongvisu

TopBorderColor

bongvisu avatar May 07 '22 01:05 bongvisu

bump

minisbett avatar Jun 05 '22 08:06 minisbett

This bug is still present in the 1.1 version.

Haky00 avatar Jun 14 '22 12:06 Haky00

Any developer's comment? Nope?

pavel-zhukov avatar Jun 19 '22 04:06 pavel-zhukov

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;
  }

  // ...

}

pavel-zhukov avatar Jul 31 '22 16:07 pavel-zhukov

Additional bug related to this wrong border.

If you want to disable resizing for your app and add the code:

if (appWindow.Presenter is OverlappedPresenter p)
       p.IsResizable = false;

then the side and bottom borders will not support resizing and won't show the resizer cursor, but the top border will still show the resize cursor (but resizing will not actually work):

image

@pavel-zhukov your fix deals with both issues - it fixes the color and also gets rid of the wrong resize cursor.

I hope the team will do something about it; these hacks are ugly.

progmars avatar Aug 21 '22 15:08 progmars

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 28 '23 22:07 github-actions[bot]

This is still an Issue, not sure if its WinUI 3 related, or WinAppSDK https://github.com/microsoft/microsoft-ui-xaml/issues/8743

mdtauk avatar Jul 29 '23 00:07 mdtauk

I would close this issue because the other issue mentioned here is more accurate : in high contrast setting, parts of top border is missing. I would follow that issue to track it. Closing it as dup.

pratikone avatar Feb 23 '24 03:02 pratikone

So where exactly is this going to be fixed?

bogdan-patraucean avatar Mar 15 '24 21:03 bogdan-patraucean

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 .

pratikone avatar Mar 21 '24 00:03 pratikone