Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HasChildren is only evaluated once #132

Open
SuperJMN opened this issue Oct 5, 2022 · 0 comments
Open

HasChildren is only evaluated once #132

SuperJMN opened this issue Oct 5, 2022 · 0 comments

Comments

@SuperJMN
Copy link
Contributor

SuperJMN commented Oct 5, 2022

The hasChildrenSelector in HierarchicalExpanderColumn is only evaluated once. This means that, if the children collection is modified, the selector should be re-evaluated.

Repro

I've prepared a minimal repro HERE.

Run it and you will see how the 2 TreeDataGrids behave differently even though they're using the same tree (same nodes).

TreeDataGridExpandBug_jY7ER5C7s0.mp4

Please, notice that if you run the sample and click the expand button before the root has any children, it won't be expandable either!

Manual repro:

In case you want to warm up your hands, you can create your own repro with the steps below:

  1. Inside a ViewModel's constructor, create a TreeDataGrid with a root node and let its children be inside an ObservableCollection.
  2. Create a Source of type HierarchicalTreeDataGridSource.
  3. Create a HierarchicalExpanderColumn where the hasChildSelector is set to node.Children.Any(). Put a breakpoint inside this lambda expression.
  4. Don't add any children in the root node.
  5. Put code that will add children to the collection AFTER the TreeDataGrid is displayed on the screen. For example, a Button that will add children when clicked.

Result: If you add children after the TreeDataGrid is initialized and shown, the breakpoint won't be hit, and the root node will never be expandable (the little expander won't show)

Expected: The breakpoint should be hit and the "has children" condition should be re-evaluated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant