Simnico99 / MicaWPF

This is a library to make Mica available in WPF.
MIT License
206 stars 11 forks source link

[Bug]: Maximize window to cover taskbar height when window width is limited #76

Closed CodingOctocat closed 1 year ago

CodingOctocat commented 1 year ago

Describe the bug

If the window is maximized when MaxWidth is set, the contents of the window will overflow to the taskbar.

<mica:MicaWindow x:Class="MicaWpfTest.MainWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:mica="clr-namespace:MicaWPF.Controls;assembly=MicaWPF"
                 Title="MainWindow"
                 Width="800"
                 Height="450"
                 MaxWidth="1000"
                 SizeToContent="WidthAndHeight"
                 TitleBarType="WinUI"
                 mc:Ignorable="d">
    <StackPanel>
        <mica:Arc Height="30" />

        <mica:Button Content="12321" />

        <mica:TextBox />

        <Button Content="123213213" />
    </StackPanel>
</mica:MicaWindow>

image

Steps to reproduce the bug

As above.

Expected behavior

No response

Screenshots

No response

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

.Net Version

.NET 7.x

Additional context

No response

Simnico99 commented 1 year ago

Without MicaWPF image

With MicaWPF Maximized with limited witdth: image

I will need more precision has I am not sure to understand what is the issue.

CodingOctocat commented 1 year ago

I created a new blank project without MicaWPF and have the same problem, so it's a problem with WPF itself! Can MicaWPF fix this?

  1. Set MaxWidth,then maximize window.(title bar is not normal, and Bottom at the back of the taskbar)

image

The expected result should be something like this:

image

Simnico99 commented 1 year ago

Ah yes let me take a look at it

CodingOctocat commented 1 year ago

We know that if the window is set to MaxWidth, then when maximized it will be maximized on the left side of the screen, which is a bad experience, and the correct behavior is to maximize with the window in the center, but it seems like a lot of work to do this, and the behavior of the maximize button has to be override (including double-clicking on the title bar to maximize, Win+UpArrow, and anything else that maximizes the window)

Simnico99 commented 1 year ago

Do you think I should Actually prevent the user from maximizing the window when the maxwitdh value is not the default?

CodingOctocat commented 1 year ago

As shown in the picture:

When I maximize the window:

image

Simnico99 commented 1 year ago

As shown in the picture:

When I maximize the window:

image

Yes Yes I Understood it's just that I will have to hook into all sort of events to figure this one out.

Its a complex task. I will see what I come up with.

Simnico99 commented 1 year ago

image

Works with everything pushing to main branch.

Simnico99 commented 1 year ago

Pushing version 6.1.3 it is now fixed.