![]() |
| How to Set WinUI 3 Window Width and Height Without AppWindow |
If you have worked with WinUI 3 window sizing, you have probably used Window.AppWindow to control the size of your application window.
That approach works, but it can become unnecessarily complicated when all you want to do is set a window width, height, minimum size, or maximum size.
A new experimental Windows App SDK API makes this much simpler.
The Windows App SDK 2.3.2 Experimental release introduced direct sizing properties on the WinUI Window class:
Window.WidthWindow.HeightWindow.MinWidthWindow.MinHeightWindow.MaxWidthWindow.MaxHeight
These properties let applications work with window dimensions in logical client pixels without reaching through Window.AppWindow and manually converting between logical and physical pixels. Microsoft introduced these APIs in the Windows App SDK 2.3.2 Experimental release on July 30, 2026. Microsoft Learn
Important: These APIs are currently experimental. They should not be treated as stable production APIs yet.
The Old AppWindow Approach
Before these new properties, developers commonly used AppWindow when they needed to manipulate the window size.
A simplified example looks like this:
var appWindow = AppWindow;
appWindow.Resize(new SizeInt32
{
Width = 1200,
Height = 800
});
The problem becomes more noticeable when DPI-aware sizing is involved.
Depending on the API being used, you may need to work with physical pixels and perform conversions between the window's logical client dimensions and physical screen pixels.
For a simple requirement such as "make my application open at 1200 × 800", that can feel like unnecessary windowing code.
The New Window.Width and Window.Height APIs
The experimental APIs introduce a much simpler approach.
Instead of going through AppWindow, you can set the dimensions directly on the WinUI Window.
this.Width = 1200;
this.Height = 800;
For example:
public MainWindow()
{
InitializeComponent();
Width = 1200;
Height = 800;
}
This is much easier to read and makes the intention obvious.
You are saying directly:
Set this application's window to 1200 logical client pixels wide and 800 logical client pixels high.
According to Microsoft's release notes, the new properties provide a DPI-aware way to get and set window size in logical client pixels directly from code or markup.
Set the Window Size from XAML
One particularly useful part of the new API is that the properties can also be used from markup.
For example:
<Window
x:Class="MyWinUIApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="1200"
Height="800">
<Grid>
<TextBlock
Text="My WinUI 3 Application"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</Window>
This can make window configuration much cleaner because the desired dimensions are visible directly in the XAML.
Set a Minimum Window Size
Another useful addition is the ability to define minimum dimensions.
For example, suppose your application's layout becomes difficult to use below 900 × 600.
You can define:
MinWidth = 900;
MinHeight = 600;
Or in XAML:
<Window
x:Class="MyWinUIApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="1200"
Height="800"
MinWidth="900"
MinHeight="600">
<Grid>
<Frame x:Name="ContentFrame" />
</Grid>
</Window>
Now the user can resize the window, but the window cannot become smaller than the minimum dimensions you specified.
Set a Maximum Window Size
The API also provides maximum size constraints.
For example:
MaxWidth = 1600;
MaxHeight = 1000;
You can combine all four constraints:
Width = 1200;
Height = 800;
MinWidth = 900;
MinHeight = 600;
MaxWidth = 1600;
MaxHeight = 1000;
This gives you a controlled resizing range while still allowing the user to resize the application.
A Complete Example
Here is a simple example of a WinUI 3 window using all the new sizing properties:
public MainWindow()
{
InitializeComponent();
Width = 1200;
Height = 800;
MinWidth = 900;
MinHeight = 600;
MaxWidth = 1600;
MaxHeight = 1000;
}
The resulting behavior is straightforward:
- Initial width: 1200
- Initial height: 800
- Minimum width: 900
- Minimum height: 600
- Maximum width: 1600
- Maximum height: 1000
Why This Is Better for DPI-Aware Applications
One of the biggest advantages of these APIs is that developers no longer need to manually convert between logical and physical pixels for this basic window-sizing scenario.
Microsoft specifically describes the new properties as DPI-aware and based on logical client pixels.
This is important for applications running on displays with different scaling settings.
For example, a user might have:
- A 100% scaling display
- A 125% scaling display
- A 150% scaling display
- A high-DPI laptop display
Using logical dimensions makes your application's sizing code easier to reason about because you are not manually calculating physical pixel values.
Do You Still Need AppWindow?
Yes.
The new APIs do not mean that AppWindow is obsolete.
AppWindow remains useful for advanced Windows window-management scenarios.
For example, if your application needs detailed control over windowing behavior or other AppWindow-specific functionality, you may still need to work with it.
The new Window.Width and Window.Height properties are mainly useful when your requirement is simply to control the size of the WinUI window.
Think of it this way:
Simple window sizing
↓
Window.Width / Height
Window.MinWidth / MinHeight
Window.MaxWidth / MaxHeight
Advanced window management
↓
Window.AppWindow
AppWindow APIs
Check Your Windows App SDK Version
There is an important version requirement for these APIs.
The direct Window sizing properties were introduced in the Windows App SDK 2.3.2 Experimental release on July 30, 2026.
Microsoft's Windows App SDK release notes currently distinguish stable, preview, and experimental releases, so you should not assume that an experimental API is available in the latest stable package.
Before using these APIs, check which Windows App SDK package your project references.
<PackageReference
Include="Microsoft.WindowsAppSDK"
Version="2.3.2-ExperimentalA" />
Use the exact package version appropriate for your project and Microsoft's current release channel. Do not move a production application to an experimental package simply to use these properties.
When Should You Use This API?
The new properties are particularly interesting for applications that need predictable desktop layouts.
Examples include:
- Document editors
- Image converters
- PDF applications
- Developer tools
- Media applications
- Business applications
- Dashboard applications
- Utility applications
For example, a PDF editor might want an initial size of 1400 × 900 while preventing the window from becoming too small for its document toolbar and page preview.
That can now be expressed directly through the window's sizing properties.
Common Mistake: Treating Experimental APIs as Stable
The biggest thing to remember is that these properties are currently experimental.
Microsoft explicitly labels the Windows App SDK 2.3.2 release as an experimental release and invites developer feedback on these APIs.
That means you should be careful about using them in applications that need long-term API stability.
For production applications, verify the current Windows App SDK stable release and confirm whether these properties have moved into a stable release before depending on them.
Conclusion
Setting the size of a WinUI 3 window has traditionally involved AppWindow APIs and, in some scenarios, DPI conversions.
The new experimental Window.Width, Window.Height, Window.MinWidth, Window.MinHeight, Window.MaxWidth, and Window.MaxHeight properties provide a much simpler approach.
For a basic requirement such as:
Width = 1200;
Height = 800;
you can now express the intent directly on the WinUI Window.
The APIs are still experimental, so treat them as an upcoming capability rather than a production-stable replacement for every AppWindow scenario.
For developers building modern WinUI 3 applications, however, this is an API worth watching because it significantly reduces the amount of window-sizing code needed for common scenarios.
Frequently Asked Questions
Can I set WinUI 3 Window.Width directly?
Yes. Windows App SDK 2.3.2 Experimental introduced a direct Window.Width property for setting and getting the window width in logical client pixels.
Can I set WinUI 3 Window.Height directly?
Yes. The experimental API also provides Window.Height.
Can I set minimum and maximum window sizes?
Yes. The experimental API provides MinWidth, MinHeight, MaxWidth, and MaxHeight.
Do I still need AppWindow in WinUI 3?
Yes. AppWindow remains useful for advanced window-management scenarios. The new Window sizing properties are intended to simplify common window-size operations.
Are Window.Width and Window.Height stable APIs?
Not yet. They were introduced in the Windows App SDK 2.3.2 Experimental release, so developers should treat them as experimental and verify their availability in a stable release before relying on them for production applications.

Comments
Post a Comment