microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.34k stars 677 forks source link

Xaml island: ContentDialog backdrop does not resize when window is resized #3577

Open Isopod opened 3 years ago

Isopod commented 3 years ago

The dialog backdrop stays at its initial size even when the island window is resized while the dialog is open.

Steps to reproduce the bug

  1. Download demo project and run it
  2. Click on the button in the middle
  3. Dialog opens
  4. Resize the window
  5. Backdrop is not resized

Expected behavior The backdrop should always cover the entire area.

Screenshots Video: https://imgur.com/a/AU93vh4

I hope it's clear what the problem is. I added some colored rectangles on the sides, because otherwise the backdrop is the same color as the window and you can't see it.

Version Info Windows Kit 10.0.18362.0

Windows app type: UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT
ranjeshj commented 3 years ago

Possibly related to #3307

sylveon commented 3 years ago

Can confirm as well:

image

zadjii-msft commented 3 years ago

Is there any sort of crazy workaround we could do for this? Something to cause the shadow to recalculate it's size? This is also evident for the Terminal if you do About, close it, resize the window, then do About again

marcelwgn commented 3 years ago

Have you tried calling UpdateLayout upon window resizing @zadjii-msft ?

zadjii-msft commented 3 years ago

Have you tried calling UpdateLayout upon window resizing @zadjii-msft ?

Unfortunately, yea. I tried adding a MyContentDialog().UpdateLayout() call inside our Page's SizeChanged event, but unfortunately that doesn't seem to resize the SmokeLayerBackground of the ContentDialog. Something about PrepareSmokeLayer not getting called during a resize?

zadjii-msft commented 3 years ago

Also tracked internally at MSFT:35583503

dongle-the-gadget commented 1 year ago

Seems that passing WM_SIZE to the underlying CoreWindow works.

#include <corewindow.h>
#include <winrt/Windows.UI.Core.h>

using namespace winrt::Windows::UI::Core;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message)
   {
      case WM_SIZE:
      {
         HWND coreWindowInterop;
         CoreWindow::GetForCurrentThread().as<ICoreWindowInterop>()->get_WindowHandle(&coreWindowInterop);
         PostMessage(coreWindowInterop, message, wParam, lParam);

         break;
      }
   }
}
sylveon commented 1 year ago

Can confirm this solves the problem.

github-actions[bot] commented 1 year ago

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.

zadjii-msft commented 1 year ago

This is still an issue. No one should need to rely on that janky workaround.

dongle-the-gadget commented 1 year ago

I think they aren't going to spend a lot of effort fixing this since XAML Islands v2 (for WinUI 3) is around the corner.