Skip to content

TreeView control will cause app to hang when using virtualization + an item in ItemsSource is null #11331

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work]
Found this issue after upgrading a project from .Net Framework 4.8 to .NET 8. It seems there has been a change maybe from prior versions to how virtualization works.

I have a TreeView that gets bound to a list, and found that an app (dispatcher) hang will occur under the specific conditions that:

1: At least one item in the ItemsSource collection is null
2: The VirtualizingPanel.IsVirtualizing="true" property is set on the TreeView
3: The default style for the ItemContainerStyle specifies that IsExpanded is true

If these conditions are met, the app dispatcher will become flooded with calls to ArrangeOverride ie. will keep trying to rearrange the VirtualizingStackPanel for some reason, causing all user interactivity to freeze and the application to lock up.

This happens on both .NET 5 and 8 as far as I have tested this.

Please see attached documents for a sample MainWindow XAML and code-behind.

MainWindow.zip

Note that changing either the ItemContainerStyle IsExpanded, the virtualization mode or by removing any null references in the ItemsSource collection, this "bug" seems to not occur. I suspect something in how TreeViewItems get rendered means that they keep trying to reevaluate their size in this niche instance where the container has nothing to render, but at this point my knowledge of the WPF layout/virtualization system runs out.


Original Comments

Feedback Bot on 19/9/2025, 08:57 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    vsfeedbackmetadata: To identify issues sourced from VSFeedback

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions