Avalonia
Avalonia copied to clipboard
Make GridSplitter not limited to be only working when logical parent is Grid
What does the pull request do?
See https://github.com/AvaloniaUI/Avalonia/issues/12030 Previously I had another PR, its closed now. This PR fix the issue.
What is the current behavior?
If there is an ItemsControl which has a GridSplitter within its Items, and the ItemsPanel is a Grid. In this case, the GridSplitter don't work because in the private void InitializeData(bool showsPreview) method, It only consider its parent is Grid or not. For another instance, I want to place GridSplitter not directly as a child under the Grid, but child of its child. In such case GridSplitter also won't work.
What is the updated/expected behavior with this PR?
Any previously working use of GridSplitter should not break. GridSplitters placed as child of child should work. GirdSplitters in ItemsControl that use Grid as ItemsPanel should work.
How was the solution implemented (if it's not obvious)?
If the local parent is not grid, it then find nearest local ancestor that is a grid. In ResizeData, a field named GridChild is added. It is the child of Grid that is the GridSplitter itself or its ancestor. This reference is used for getting and setting ColumnsProperty, ColumnsSpanProperty, etc.
Checklist
- [ ] Added unit tests (if possible)?
- [ ] Added XML documentation to any related classes?
- [ ] Consider submitting a PR to https://github.com/AvaloniaUI/Documentation with user documentation
Breaking changes
Previously not working GridSplitters (which may be made so intensionaly) may be working now if they are placed as a decendant of a Grid.
Obsoletions / Deprecations
N/A
Fixed issues
Fixes https://github.com/AvaloniaUI/Avalonia/issues/12030