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

TreeViewItem doesn't always handle IsExpanded binding properly #2112

Closed
arcadiogarcia opened this issue Mar 13, 2020 · 8 comments
Closed

TreeViewItem doesn't always handle IsExpanded binding properly #2112

arcadiogarcia opened this issue Mar 13, 2020 · 8 comments
Labels
area-TreeView bug Something isn't working no-issue-activity team-Controls Issue for the Controls team

Comments

@arcadiogarcia
Copy link
Contributor

I am trying to expand/collapse values in a TreeView procedurally by binding the IsExpanded property in each TreeViewNode. This initially works, but there seems to be a bug that break this behavior.

Steps to reproduce the bug
Steps to reproduce the behavior:

  1. Clone and run this project https://github.com/arcadiogarcia/ListViewBugRepro
  2. Click Refresh, tree gets populated
  3. Click Expand, tree expands properly
  4. Click Refresh, tree gets populated again
  5. Click Expand, tree fails to expand properly. Now it can only expand the first level, or the last level that was closed automatically.

Expected behavior
The values of IsExpanded should still be honored after reassigning the value of ItemsSource. It seems that expansion only works correctly for the first tree that is assigned, and fails for the subsequent.

Screenshots
Tree after step 3:
image
Tree after step 5, note that IsExpanded == true but the node is not expanded:
image

Version Info
Running 18363

NuGet package version:
Can repro with both the inbox controls and Microsoft.UI.Xaml 2.3.200213001

Windows 10 version Saw the problem?
Insider Build (xxxxx)
November 2019 Update (18363) Yes
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Mobile
Xbox
Surface Hub
IoT
@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Mar 13, 2020
@arcadiogarcia
Copy link
Contributor Author

Ok I just saw that this is a duplicate of #1790 , I didn't find it before because it was closed. When should i expect this to make it to a stable build?

@ranjeshj
Copy link
Contributor

@arcadiogarcia the latest pre-release build should already have this fix. Can you use that ? The next stable release build is planned by the end of the month. Thanks.

@ranjeshj ranjeshj added the duplicate This issue or pull request already exists label Mar 13, 2020
@msft-github-bot msft-github-bot removed the needs-triage Issue needs to be triaged by the area owners label Mar 13, 2020
@arcadiogarcia
Copy link
Contributor Author

arcadiogarcia commented Mar 16, 2020

@ranjeshj I tried updating to version 2.4.0-prerelease.200203002 but I can still repro the issue, here is my example: https://github.com/arcadiogarcia/ListViewBugRepro

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Mar 16, 2020
@ranjeshj ranjeshj reopened this Mar 17, 2020
@ranjeshj
Copy link
Contributor

@kaiguo can you take a quick look please ? I expected this to be fixed with your change.

@ranjeshj ranjeshj added area-TreeView bug Something isn't working team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners duplicate This issue or pull request already exists labels Mar 17, 2020
@michael-hawker
Copy link
Collaborator

@arcadiogarcia the original issue finally got a post from the bot saying it should be in release v2.4.0-prerelease.200322001

@michael-hawker
Copy link
Collaborator

I've tested this out now and this appears to work, though when I rebind the collection, I do see that it does 'blink' between showing the root and having it expanded.

@HLCaptain
Copy link

HLCaptain commented Aug 3, 2021

I have the same problem or a little bit different with my app. https://github.com/HLCaptain/Hypr
Check the dev branch. I use WinUI 2.61. When I have no project open, I bound some dummy data to my TreeView.
Related files:

  • ViewModels/Editor/EditorTreeViewModel.cs
  • Views/CustomControls/EditorTreeControl.xaml
  • Views/CustomControls/EditorTreeControl.xaml.cs

What I did:
Opened node "No project" and "Child1"
image

  • Closed "No project", then reopened it
    image
    Unexpected: "Child1" should be open.
  • Opened "Child1" and closed "No project", then opened "No project" again.
    Unexpected: "Child1" should be open. But it looks like, the "No project" node is some kind of bug loop, because from now on, "Child1"'s expansion toggles as I open and close "No project".

It gets worse with more data down the road. Children nodes' expansion toggles unexpectadly and interrupts workflow.
Bug appeared when I ported properly working solution from code-behind to MVVM (to ViewModel) and bound the data.

OS Build: 19043.1110

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TreeView bug Something isn't working no-issue-activity team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

5 participants