WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

IsMaximizable Ignored When Content Extends into Title Bar

Open jamespack opened this issue 2 years ago • 10 comments

Describe the bug

AppWindow::Presenter::IsMaximizable is ignored when MainWindow::ExtendsContentIntoTitleBar(true);

image image

Steps to reproduce the bug

  1. New Blank WinUI 3 Project
  2. MainWindow::ExtendsContentIntoTitleBar(true)
  3. Get the AppWindow using <winrt/Microsoft.UI.Interop.h>
  4. Get the AppWindow::Presenter
  5. Set Presenter::IsMaximizable(false);

Expected behavior

The maximize button should be disabled the same as when the content is not extended into the title bar.

Screenshots

See above

NuGet package version

Windows App SDK 1.2.4: 1.2.230217.4

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

jamespack avatar Feb 27 '23 01:02 jamespack

Could you share your code to reproduce the bug?

sotanakamura avatar Feb 27 '23 13:02 sotanakamura

Yep. Give me a few mins. I'll push a branch and link it here.

jamespack avatar Feb 27 '23 15:02 jamespack

Here you go.

https://github.com/jamespack/IsMaximizableBug

jamespack avatar Feb 27 '23 16:02 jamespack

I cannot resolve the bug, but I will share information related to AppWindow. https://github.com/microsoft/microsoft-ui-xaml/issues/7628 https://github.com/microsoft/microsoft-ui-xaml/issues/8201

sotanakamura avatar Feb 28 '23 03:02 sotanakamura

Thanks for the material. I was able to get it working by setting an empty custom titlebar and setting its ExtendsContentIntoTitleBar property to true. Thats a hack though. Id still say this is a bug unless the intention is to remove this api at some point in favor of the AppWIndow api.

image

jamespack avatar Mar 02 '23 02:03 jamespack

With a hopefully improved AppWindow API :)

jamespack avatar Mar 02 '23 02:03 jamespack

Unfortunately, there are 2 different "ExtendsContentIntoTitleBar" right now:

  • WinUI 3's custom title bar in Microsoft.UI.Xaml.Window class
  • AppWindow's custom title bar in Microsoft.UI.Windowing.AppWindowTitleBar

Since the IsMaximizable property is set on an AppWindow presenter, you would need to use appWindow.TitleBar().ExtendsContentIntoTitleBar(true); for it to function properly.

peterjtan avatar Mar 15 '23 01:03 peterjtan

The entire window/title bar api is kind of messy. I know it's still relatively early. So hoping that improved over time. Over all super excited about Windows Apps and the future for windows devs!

jamespack avatar Mar 16 '23 14:03 jamespack

I hit the same and had a user report this in WinUIEx as well. The IsMinimizable and IsMaximixable does gray out the buttons, but they are still fully interactive. The proposed workaround by @peterjtan had no effect for me.

dotMorten avatar Oct 16 '23 06:10 dotMorten

Unfortunately, there are 2 different "ExtendsContentIntoTitleBar" right now:

  • WinUI 3's custom title bar in Microsoft.UI.Xaml.Window class
  • AppWindow's custom title bar in Microsoft.UI.Windowing.AppWindowTitleBar

Since the IsMaximizable property is set on an AppWindow presenter, you would need to use appWindow.TitleBar().ExtendsContentIntoTitleBar(true); for it to function properly.

Thanks for saving my life.

HO-COOH avatar Apr 30 '24 08:04 HO-COOH

Closing this as duplicate. microsoft/microsoft-ui-xaml#8666 looks like a direct duplicate which we have an internal tracking issue for.

codendone avatar Jun 06 '24 16:06 codendone