Microsoft-ui-xaml: Proposal: Window Width/Height in Desktop

Created on 23 Jun 2020  路  5Comments  路  Source: microsoft/microsoft-ui-xaml

Proposal: Support Window Width/Height when in Desktop

Summary

For WinUI in Desktop apps:

  • Support setting Width and Height on Window in XAML.
  • Support setting d:DesignWidth and d:DesignHeight on Window in XAML.
<Window Width="1200" Height="600"
        d:DesignWidth="1000" d:DesignHeight="500">

Rationale

Many developers doing WinUI in Desktop will have a background in WPF and/or simply not be interested in doing a responsive design -- this is "in Desktop" after all. Without the ability to set Window size in a traditional way, I believe adoption will suffer due to too much forced change.

area-AppWindow feature proposal needs-winui-3 team-Reach winui3preview

All 5 comments

@JVimes, thanks for opening this request. I believe there should be APIs that allow developers to do this. The APIs should work for both, UWP and Desktop.

@marb2000 It appears not:
image

@JVimes, thanks for opening this request. I believe there should be APIs that allow developers to do this. The APIs should work for both, UWP and Desktop.

I'm wondering if there is any API to manage window size/position at all?

While these APIs doesn't exist in Desktop WinUI 3 apps, I published a sample to workaround it using the Win32 APIs.

Using the SetWindowPos API you can set the size and/or the position of a Window object.

Thanks for the workaround, @marb2000. The code also looks like a starting point to address the problem.

Was this page helpful?
0 / 5 - 0 ratings