Feature to store the window size and position on Windows and restore that position and size on next launch #1777
Closed
bmacombe
started this conversation in
New Feature Discussions
Replies: 3 comments 7 replies
-
Not looked into it but would we want to do this for Desktop so cover Windows and Mac etc? |
Beta Was this translation helpful? Give feedback.
0 replies
-
@pictos Mentioned in today's standup that the WinUIEx library already supports this feature: https://github.com/dotMorten/WinUIEx |
Beta Was this translation helpful? Give feedback.
7 replies
-
Closed as answered, if closed in error please let us know to re-open. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
WinUI does not store the position and size of a window on close like UWP. So it is up to the application to implement its own mechanism.
I have implemented this feature in my Maui app and think it could be a useful feature too others.
The stored position is validated against the current display areas of the system in case the display configuration has changed since the Maui app was last started. If the stored position is no longer valid, the default WinUI position is used (basically do nothing to the window position on startup)
The basic logic flow for this feature is contained in a AppendToMapping on the WindowHandler.
a) All the current DisplayAreas of the system are retrieved
b) The stored position is checked against current DisplayAreas
c) If the position is found to be within the current display areas (either fully contained or allow to cross displays at the users option) The AppWindow is moved and sized to the stored location. If no valid position is found, nothing is done
All operations are wrapped in a try/catch to just ignore errors and the default behavior of just loading the default WinUI window location is used.
If approved I'm happy to provide an implementation.
Beta Was this translation helpful? Give feedback.
All reactions