wpf 如果列表加载超多数据变的卡顿时,使用VirtualizingStackPanel


如果列表加载超多数据变的卡顿时

<ListBox >
  <ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
      <VirtualizingStackPanel Orientation="Vertical" />//加这句
    </ItemsPanelTemplate>
  </ItemsControl.ItemsPanel>

  <ItemsControl.ItemTemplate>
    <DataTemplate>

    </DataTemplate>
  </ItemsControl.ItemTemplate>
</ListBox>

解释:

When a WPFItemsControlis bound to a large collection data source, with UI virtualization enabled, the control will only create visual containers for the items that are actually visible (plus a few above and below). This is typically only a small fraction of the entire collection. When the user scrolls, new visual containers are created as items become visible, and old containers are disposed when items are no longer visible. When container recycling is enabled, it will reuse visual containers instead of creating and disposing, avoiding the object instantiation and garbage collection overheads.

优质内容筛选与推荐>>
1、仿淘宝网产品列表的收起展开、隐藏显示代码
2、bzoj 1024 暴力深搜
3、ruby 1.9 中 to_enum的实现
4、ABI (应用程序二进制接口)
5、记一次曙光易通指静脉开发中遇到的坑


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号