UiWindow this.Height is not adjusting in code
Nobody has claimed this yet.
- 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.
Second screenshot (changing window type lost the theming, so ignore the white screen) is the base WPF Window with this.Height = 1100;
OS version
Windows 10 .0.19044
.NET version
.net 6
WPF-UI NuGet version
WPF UI 2.0.3
Additional context
Other options such as this.MinHeight do work using the UiWindow
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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