XamlPadSample-Step 1d-Window
My Window now works exactly like I want:
- remembers WindowState it was in (Maximized, Restored, Minimized, FullScreen)
- remembers monitor is was on
- remembers where to restore to.
I had to use a bit more code that I would have liked, but it all is good. (Ideally, WPF Window can be improved to make this scenario work with a bit less code. Until then, the workarounds could likely be factored into a nice attached behavior…but I’m not planning on doing that. Thanks to Joe/Eric for helping me work through those issues.)
[overview of project: XamlPadSample page –today’s source snapshot: 2010-01-24 Source Snapshot]
Update to Backlog.txt in Source:
---------------------------------------------
2010/01/24 - posted v1d - Window - focused on more fixes to Window remembering state
---------------------------------------------
Fixed: Maximized or fullscreen windows on 2nd monitor will launch on primary monitor after relaunch. (thanks Joe)
XamlPadHelpers project
•XamlPad.xaml
◦Added AcceptsTab="True" to TextBox, so I can put a tab into the textbox.
(TODO: should I add a feature to turn a tab into spaces?)
XamlPadSample project
•MainWindow.xaml
◦Removed binding to Window.WindowState. In order to fix the maximize on 2nd monitor bug, I had to move this to code.
(Ideally Window should have worked like I tried. Bugs are opened.)
•MainWindow.xaml.cs
◦Dealt with WindowState after the window source was initialized.
◦In closing handler, worked around issue where sometimes the saved height and width was full screen, even after I Restored the window.