WPF ListView Very Slow Performance - Why? (ElementHost, or Other Reason?) WPF ListView Very Slow Performance - Why? (ElementHost, or Other Reason?) wpf wpf

WPF ListView Very Slow Performance - Why? (ElementHost, or Other Reason?)


Use virtualization

<ListView ItemsSource="{BindingNames}"Name="lv">            <ListView.ItemsPanel>                <ItemsPanelTemplate>                   <!--<StackPanel/>                    If StackPanel was used, the memory consumed was over 2GB and dead slow.                    -->                   <VirtualizingStackPanel>                    <!--Memory footprint is only 200 mb-->                    </VirtualizingStackPanel>                </ItemsPanelTemplate>            </ListView.ItemsPanel>            <ListView.ItemTemplate>                <DataTemplate>                    <TextBlock Text="{Binding}"/>                </DataTemplate>            </ListView.ItemTemplate>        </ListView> 


You may also want to check this excellent article on the Code Project:

WPF: Data VirtualizationBy Paul McCleanhttp://www.codeproject.com/KB/WPF/WpfDataVirtualization.aspx

It show you a much better approach at minimal memory and bandwidth usage.


I had a case where the answers presented here didn't solve my problem. In my case, setting the MaxHeight property of the ListView to a value larger than the actual displayed height solved it immediately, thanks to this answer here, even if I cannot explain how and why it worked.