Add window state save/restore feature#2106
Add window state save/restore feature#2106Zakariathr22 wants to merge 8 commits intomicrosoft:mainfrom
Conversation
Adds support for saving and restoring main window size, position, scale, and maximized state between sessions. Introduces new settings properties and UI toggle for enabling/disabling this feature. Implements `WindowStateHelper` and `WindowState` classes for state management. Window state is restored on load and saved on close if enabled.
|
@Zakariathr22 I haven't tested this yet, will do soon! How will this work when moving between monitors? E.g. opening the app on multi-monitor setup, and then unplugging and only using the laptop's screen? |
I tested it, and the window consistently reopens on the main screen after being closed and launched again. How the code works:
|
| </StackPanel> | ||
| </toolkit:SettingsCard> | ||
|
|
||
| <toolkit:SettingsCard Header="Save window state" |
There was a problem hiding this comment.
This shouldnt be an option, either we support it and it works or we dont support it.
There was a problem hiding this comment.
Can we negotiate this?
Sometimes, when I use applications that have this functionality, I actually wish it wasn’t enabled. I may resize the window for a specific task, but that doesn’t mean I’ll need it at that size again later.
What if we enable the feature by default (make it true), but also keep providing users with the option to disable it if they prefer not to use it?
There was a problem hiding this comment.
Do we have use cases why it should (not) be optional? E.g. when I look at most (inbox) Windows apps they have logic to do this, without the option to turn it off?
|
@Zakariathr22 We can use WindowsAppSdk Built-in API for this. Spec is ready and is working fine. @marcelwgn Can you ask your internal friends whether this API will be included in the stable v2 release or not? It is currently available in experimental 5. |
We can proceed with closing this PR once we have confirmation that the API will be part of the upcoming release. |
|
@Zakariathr22 @ghost1372 I'm following up internally to understand what to expect from these APIs. Will circle back here |
Description
WindowStateHelperandWindowStateclasses for state management.Settingspage).Motivation and Context
How Has This Been Tested?
Manually tested
Screenshots (if appropriate):
Types of changes