lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.67k stars 748 forks source link

UiWindow this.Height is not adjusting in code #732

Open project-sbc opened 1 year ago

project-sbc commented 1 year ago

Describe the bug

I am setting the height dynamically in code after load using the loaded event this.Height = wpfScreen.WorkingArea.Height; On my current monitor this is 1440. However, the window size will not respect this value and remains whatever it is in xaml.

I have dpiawareness enabled in an app.manifest

Here is my UiWindow xaml: `<ui:UiWindow x:Class="Everything_Handhelds_Tool.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Everything_Handhelds_Tool" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" mc:Ignorable="d" WindowStyle="None" Title="Everything Handhelds Tool" Left="0" Top="0" Width="500" Height="700" ResizeMode="NoResize" AllowsTransparency="True" Loaded="UiWindow_Loaded" Closing="Window_Closing"

`

To Reproduce

If I convert the window to a typical WPF Window ONLY changing the xaml and the class base `<Window x:Class="Everything_Handhelds_Tool.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Everything_Handhelds_Tool" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" mc:Ignorable="d" WindowStyle="None" Title="Everything Handhelds Tool" Left="0" Top="0" Width="500" Height="700" ResizeMode="NoResize" AllowsTransparency="True" Loaded="UiWindow_Loaded" Closing="Window_Closing"

`

the loaded event's this.Height property works correctly.

Expected behavior

Expect the window height to adjust using this.Height during runtime.

Screenshots

First screenshot is the WPF UI UiWindow with this.Height = 1100; The height is not 1100.

using ui:UiWindow

Second screenshot (changing window type lost the theming, so ignore the white screen) is the base WPF Window with this.Height = 1100; using Window height sets to 1100 as written in c#

OS version

Windows 10 .0.19044 image

.NET version

.net 6

WPF-UI NuGet version

WPF UI 2.0.3

image

Additional context

Other options such as this.MinHeight do work using the UiWindow

aliajboy commented 10 months ago

I have this issue too

ekomsctr commented 1 month ago

I'm in the same boat, trying to resize the UiWindow at runtime (after it is being shown, if i set the Width and Height in the window constructor it does work) with no success.

Using WPFUI 2.1 (cannot upgrade as easily since it's an already published Application and there are too many breaking change to manage at the moment).