lepoco / lepoco/wpfui

UiWindow this.Height is not adjusting in code

Open
#732 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
9.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting UiWindow's handling of Height and compare it with the base WPF Window behavior described in the reproduction. Reproduce the issue with the provided Loaded handler and the WPF-UI 2.0.3 setup, then verify that runtime height changes are respected while existing UiWindow behavior such as MinHeight continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.