GridSplitter does not work when IsItemsHost is true
See original GitHub issue- .NET Core Version: 5.0
- Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
GridSplitter
does not work, when it is added programmatically to ItemsControl.Items
that uses a Grid
with IsItemsHost="true"
Reason:
GridSplitter.InitializeData
checks if Parent
is a Grid
. In this case the LogicalParent
is the ItemsControl
.
Shouldn’t it check the VisualParent
?
repro.zip
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Itemscontrol that arrange Items with Gridsplitter-Functionality
When the Grid is set to IsItemsHost="true" I get a Error that the DefinitionsCollection is not accessable... Heres a CodeSnipped from the custom ......
Read more >How to: Resize Rows with a GridSplitter - WPF .NET ...
In this article. This example shows how to use a horizontal GridSplitter to redistribute the space between two rows in a Grid without...
Read more >WPF and Silverlight Super-Productivity: ListBoxes
Unfortunately, the grid does not automatically size to the available total width of each item. This would result in the star rating showing...
Read more >Wpf stackpanel spacing
At the moment, StackPanel does not have a property to set the distance between its controls. If you use the non-breaking space character...
Read more >How to dynamically resize WPF tab items to fit available width
xaml to create a grid with a column section containing the tab items and a grid splitter to adjust the width of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@IAmTheCShark yes sorry I meant the WPF is doing extra work. The purpose of
Panel.IsItemsHost
is to prevent the panel from having logical children. Similar withContentControl.ContentIsNotLogical
which is used with items. Your PR would make some of the items sometimes see the panel and that worries me. Maybe an opt-in (or associatingGridSplitter
with a customGrid
) would do. Maybe my counterexample is artificial and I am overly cautious, while everyone would expect the behavior you are expecting andGridSplitter
in fact should have checked visual parent. You can also create your ownGridSplitter
that behaves as suggested, although sadly this aspect is not easily overridable.I have used
Grid
as items panel many times, however, never with aGridSplitter
. That’s why I was enquiring about the scenario.The inconsistency is most visible when the items control overrides
IsItemsIsOwnContainer
. For example, whileGridSplitter
in pureItemsControl
would work, it wouldn’t work inListBox
as its visual parent would beContentPresenter
. I am getting more and more convinced myself this is not a good idea.