[Feature]Add ability to persist GridSplitter position and restore it in the next session
Describe the problem
There is no easy way to query the current splitter position and restore it alter. There is no single Position property and no event firing when the splitter is moved. One can hook up resize event of one of the controls and then query row/column definitions for width/height, but GridSplitter does it anyway; need a way to expose it for external consumption.
When restoring the previously saved position, the logic in HorizontalMove / VerticalMove can be replicated externally, but this really needs to be exposed by the control itself.
Describe the solution
Expose Position property and an event firing when it changes.
Alternatives
No response
Additional info
No response
Help us help you
None
Hello, 'dmitry007! Thanks for submitting a new feature request. I've automatically added a vote 👍 reaction to help get things started. Other community members can vote to help us prioritize this feature in the future!
@dmitry007 the sizers have no internal state, they just manipulate whatever they're attached to. So, it's up to you as the developer to remember the size of whatever is being manipulated (Grid, NavigationView, Expander, etc...).
This wouldn't be a responsibility of the sizer control itself.
You would save the size of the target and set its size when you rehydrate your state. There's no 'Position' to set on the Sizer/Splitter to position it...
The ManipulationCompleted event already on the control should give you an indication of when things have been dragged, if you need to immediately introspect state.
True, but that would involve copy-pasting the same code that GridSplitter already has in HorizontalMove / VerticalMove. Would be great to be able to re-use that code from outside to simplify the rehydration code.
@dmitry007 GridSplitter isn't sealed, but I didn't say anything about OnDragHorizontal/OnDragVertical in there and why you're trying to add extra code there?
If you just hook into the ManipulationCompleted even already there on the GridSplitter you should be able to do anything you want when the sizer has been manipulated?
I am not trying to add any code to OnDragHorizontal/OnDragVertical - I am trying to reuse the code already there to be able to restore the splitter position, which would be easy to do. The control could store the change from the initial position (double _delta=0 exposed through public Delta property?), with OnDragHorizontal/OnDragVertical incrementing that field (_delta) every time these methods are called (one can use separate counters for X and for Y). The value of the Delta property can be persisted. When the value is restored, the Delta property setter can call OnDragHorizontal/OnDragVertical to restore the splitter position.