WPF ListView on portable device - extremely slow scrolling

前端 未结 5 1750
后悔当初
后悔当初 2021-01-16 19:05

I have a GridView in a ListView contained in a ScrollViewer element.

I understand WPF draws only the visible data at runtime, for example on scrolling grids only th

相关标签:
5条回答
  • 2021-01-16 19:11

    I'm not sure it will solve the problem, but you could try using a VirtualizingPanel

    0 讨论(0)
  • 2021-01-16 19:12

    The first thing I need to point out is that WPF renders using DirectX. If DirectX is not available, then the system automatically defaults to a software renderer (which is much slower).

    Now, if DirectX is available (which is true in all full-blown computers, but not so on 'portable devices') the next problem you have is your graphics card's (or chip's) power.

    I bring this up because you mentioned that your code uses styles on a portable device (that I'm assuming is not a laptop). If so, operations that are a piece of cake on a desktop computer might be extremely slow on your portable device.

    Now, are your styles complex? or do they have a lot of render work? (i.e: complex gradients). If so, perhaps you could consider reducing (or eliminating) them from the application when it is being executed on your portable device.

    WPF provides a nice way to determine if the hardware in which the software is being executed is capable of handling the load.

    The code would be:

    int RenderTier = (RenderCapability.Tier >> 16);
    

    Now, if RenderTier == 0 then you have a video card (or chip) that cannot provide any kind of hardware acceleration, so all rendering wil be done using the WPF software renderer (on the CPU).

    If RenderTier == 1, then you have partial acceleration. Some operations will be done on the graphics card, other on the CPU

    if RenderTier == 2, you have full hardware acceleration, all rendering will be executed on the graphics card.

    0 讨论(0)
  • 2021-01-16 19:24

    If you need to create elements on load and do not let Virtualizing panel create them as users scrolls through the list, then you should simply set the VirtualizingStackPanel.IsVirtualizing property to false:

    <ListView VirtualizingStackPanel.IsVirtualizing="False">
    </ListView>
    

    As for DataGrid vs ListView performance. We found rendering time of the first one unacceptable on our project and decided to write our own grid control based on ListView. Performance difference was tremendous: from avg. DataGrid's 300ms we gained ~80ms from ListView...

    0 讨论(0)
  • 2021-01-16 19:31

    http://windowsclient.net/wpf/perf/wpf-perf-tool.aspx?

    0 讨论(0)
  • 2021-01-16 19:32

    Avoid setting the ScrollbarVisibility property to "Auto", that can degrade performance. Instead set it to "Visible", "Disabled", or "Hidden" (in your case probably "Visible").

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