Skip to content

TreeView crashes when using TemplateSelector and loading certain amount of nodes #8791

Closed as not planned

Description

Describe the bug

When adding a TemplateSelector to a TreeView with several different templates, after loading the TreeView with an ItemsSource with a certain number of elements, the App will crash complaining of an exception when trying to cast the ViewModel bount to a node.

It seems like it is trying to reuse a node but if it was bound formerly to a specific viewmodel type, and later it is bound to another type, it still tries to cast the current viewmodel to the other one's type.

A sample App is supplied.
WinUITreeviewErrors.zip

Steps to reproduce the bug

Launch the sample application and it should crash.

Expected behavior

Being able to have an items source for a TreeView, with any amount of elements of several types that should be represented through a Template selector without crashing.

Screenshots

The exception shown after launching the sample Application:

TreeViewCrash

NuGet package version

None

Windows version

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area-TreeViewbugSomething isn't workingclosed-DuplicateDescribed behavior is already captured by another issue.team-ControlsIssue for the Controls team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions