Repository navigation
Description
This issue has been moved from a ticket on Developer Community.
Using VirtualizingStackPanel can freeze the execution.
Steps to reproduce:
- Build a WPF application with TreeView, VirtualizingStackPanel , expanded nodes, release version,
- start the exe,
- scroll to the end of the tree,
- click on the scroll bar at the top and keep the left mouse button pressed.
The application freeze.
To reproduce try the following demo.:
' XAML:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<Grid>
<TreeView ItemsSource="{Binding View}"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.ScrollUnit="Item">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type local:Data}" ItemsSource="{Binding Childs}">
<Label Content="{Binding Info}"/>
</HierarchicalDataTemplate>
</TreeView.Resources>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True"/>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
</Grid>
</Window>
' ViewModel:
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Public Class ViewModel
Public Sub New()
For i = 1 To 100
Dim d As New Data With {. Info = $"Node {i:000}"}
For k = 1 To 10
Dim c As New Data With {. Info = $"Child {i:000} {k:000}"}
For l = 1 To 10
c.Childs.Add(New Data With {. Info = $"Grandchild {i:000} {k:000} {l:000}"})
Next
d.Childs.Add(c)
Next
col. Add(d)
Next
cvs. Source = col
End Sub
Private col As New ObservableCollection(Of Data)
Private cvs As New CollectionViewSource
Public ReadOnly Property View As ICollectionView
Get
Return cvs. View
End Get
End Property
End Class
' Data class
Imports System.Collections.ObjectModel
Public Class Data
Public Property Info As String
Public Property Childs As New ObservableCollection(Of Data)
End Class
Original Comments
(no comments)
Original Solutions
(no solutions)
Activity
grubioe commentedon Oct 4, 2019
Can you provide what version of Windows and .NET you are running? Thanks
iihnat commentedon Oct 11, 2019
Andriy,
We have similar problem.
Try VirtualizingPanel.VirtualizationMode="Standard". This way scrolling becomes a bit slower but at least application is not freezing in our case.
grubioe commentedon Oct 18, 2019
@AndriyGlu to help with prioritization can you provide more details on what is your business scenario where this issue surfaces? What is the application, number of users and details related to the business impact of this issues? Thank you
grubioe commentedon Oct 21, 2019
Thanks @AndriyGlu - what is the name of the encyclopedia product? Can you email me more specific information, the email is available from my GitHub profile.
27 remaining items
ju2pom commentedon Jan 7, 2020
Hi @SamBent,
First thank you for investing time and energy in this community issue.
We have the same symptom in one of our internal software (>1000 users), this time using a ListView with virtualization and grouping (groups can be expanded/collapsed). I have created an stf file and a memory dump (>2Go). How can I give them to you?
Would it be possible to test a "beta" or unofficial build of .NetFramework to check if your recent fix is effective in our scenario?
SamBent commentedon Jan 7, 2020
@ju2pom The best thing to do is open a case with Microsoft Customer Support. That will create a workspace in which we can trade large files securely and privately. If it's our bug (as this surely is), you don't get charged. Include the following information, to get it routed in the right direction
Product: .NET Framework 4.x
Category: Class Library Namespaces\System.Windows (WPF)
For the preview fix, you'll want to prepare a test machine that you can afford to rebuild; the private installation might leave your machine in a non-serviceable state (where Windows Update can't install new patches). And I'll need to know which version of .NET is installed, and the bitness (x86 v. x64).
As you probably already knew, scrolling in ListView + grouping (with expand/collapse) is handled by the same code as TreeView. So my fix will resolve your problem, if it's one of the "two independent issues" described earlier.
SamBent commentedon Jan 27, 2020
For .NET 4.6+, the fix has been released for many OS (others to follow this week). For details see the announcement.
For .NET Core 3.1.2, the fix is PR #2271.
If you are still seeing hangs after installing this fix, please open a new issue (and link to this issue, to aid discovery).
yingDev commentedon Jan 30, 2021
In my case, it is related to
UseLayoutRounding="True". changed it to "False" at some level in the tree then the bug disappeared.dotnet --version: 5.0.200-preview.20614.14