-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to set initial window size and position and restore previous values #7592
Comments
I am not sure we need API changes to improve significantly :-) |
Granted - as long as the system is able to do bounds check to validate that the restored position of the window falls within a valid range and doesn't restore to an off-screen location. Example:
In this case, it would be perfectly acceptable for the app to be opened in the valid screen, then either get its "default sizing" (behavior we see today) or retain the size it had before if the size can be contained within the screen bounds (minus the task bar). |
I started on this some time ago #4942 |
I see this issue was closed incorrectly as this was a new automatic feature rather than the support for a manual feature. |
One thing I noticed today, mac catalyst already save window size and position. So this is probably more just for windows. |
Given there's now API's to set the window size/position on windows, you can definitely handle saving and restoring this state yourself as a workaround. |
Whilst it would be nice if it worked out the box. If anyone else needs it, I've been using this workaround
|
This is fine until the layout has changed, e.g. the situation described earlier where an external monitor has been disconnected. My current workaround is to use EnumDisplayMonitors and GetMonitorInfo through P/Invoke, which works fine but obviously only on Windows. |
There is also @dotMorten's WinUIEx and it provides this feature. See the MAUI sample and particularly the configuration. Note that the feature works for Windows packaged apps only. Useful links |
@MartyIX more specifically this part of the doc: https://dotmorten.github.io/WinUIEx/concepts/Maui.html#perform-operations-when-windows-are-created |
any idea on how to easily save current window maximize state too? |
@ivanjx On Windows you can use WinUIEx to do this. See doc here: https://dotmorten.github.io/WinUIEx/concepts/Maui.html#perform-operations-when-windows-are-created |
@dotMorten thank you for the package. it works perfect. however i have read some concerns that on multi monitor when it no longer exists it may create the window outside of the bounds of the connected monitor. is that case also handled with WinUIEx? |
@ivanjx yes if the monitor layout changes since last app run, it will revert to default start up |
Description
I wish to be able to define a default starting size and position for the MAUI application and to restore the window position and size the next time the application is launched.
While I understand the paradigm of starting MAUI apps as full-screen (or close to full screen), it is very impractical for users to have ultra-wide monitors (in my case a 49" 5440x1440 monitor); I literally have to turn my head to change from the left side to the right side of the monitor.
I have a work-around for the initial window size and position* (except for not being able to determine the screen size, so I cannot do bounds checking to make sure the window is wholly within the screen for different resolutions / monitor sizes) but would prefer to have official support, cross platform to MacOS, for this functionality.
Public API Changes
Intended Use-Case
My app has two distinct modes of operation; Full mode for Desktop environments (Windows / MacOS) and Player for mobile devices (Android / iOS). On desktop environments (Windows / MacOS), full screen is not a desired initial state for the application.
If the user has resized and positioned the window in a specific location of the screen - as long as that position + size is still valid the application should re-launch to that position and size.
The text was updated successfully, but these errors were encountered: