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

后端 未结 3 1684
走了就别回头了
走了就别回头了 2020-12-14 01:36

I have a Windows Forms app, that has a single ElementHost containing a WPF UserControl... in my WPF, I have a VERY simple ListView:



        
相关标签:
3条回答
  • 2020-12-14 02:04

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

    WPF: Data Virtualization By Paul McClean http://www.codeproject.com/KB/WPF/WpfDataVirtualization.aspx

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

    0 讨论(0)
  • 2020-12-14 02:07

    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> 
    
    0 讨论(0)
  • 2020-12-14 02:21

    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.

    0 讨论(0)
提交回复
热议问题