Improve WPF DataGrid performance

后端 未结 4 2095
遇见更好的自我
遇见更好的自我 2020-11-29 01:23

In my .NET 3.5 WPF Application, I have a WPF DataGrid which will be populated with 500 columns and 50 rows. The performan

相关标签:
4条回答
  • 2020-11-29 01:57

    Check if you have property ScrollViewer.CanContentScroll set False. Setting this property to false disables the virtualization in a way will degrade the performance of your Data-grid. For more clarification refer this CanContentScroll

    0 讨论(0)
  • 2020-11-29 02:02

    There are a few options you can turn on to help you on your DataGrid object

    EnableColumnVirtualization = true
    EnableRowVirtualization = true
    

    These two are the main ones I think might help. Next try making your binding async

    ItemsSource="{Binding MyStuff, IsAsync=True}"
    

    And lastly, I've heard that setting a maximum height and width can help even if it above the max screen size, but I didn't notice a difference myself (claim had to do with auto size measuring)

    MaxWidth="2560"
    MaxHeight="1600"
    

    Also never put a DataGrid in a ScrollViewer, because you will essentially lose virtualization. Let me know if this helps!

    0 讨论(0)
  • 2020-11-29 02:19

    Set the DataGrid.RowHeight value and that will make a huge difference.

    I know this is a really old question, but I just came across it, and this was the biggest difference on my end. My default height was 25.

    0 讨论(0)
  • 2020-11-29 02:19

    Maybe try this instead of loading all 50 rows at once

    http://www.codeproject.com/Articles/34405/WPF-Data-Virtualization

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