question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
miloushcommented, May 15, 2022

@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 with ContentControl.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 associating GridSplitter with a custom Grid) would do. Maybe my counterexample is artificial and I am overly cautious, while everyone would expect the behavior you are expecting and GridSplitter in fact should have checked visual parent. You can also create your own GridSplitter that behaves as suggested, although sadly this aspect is not easily overridable.

I have used Grid as items panel many times, however, never with a GridSplitter. That’s why I was enquiring about the scenario.

1reaction
miloushcommented, May 15, 2022

The inconsistency is most visible when the items control overrides IsItemsIsOwnContainer. For example, while GridSplitter in pure ItemsControl would work, it wouldn’t work in ListBox as its visual parent would be ContentPresenter. I am getting more and more convinced myself this is not a good idea.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found