zoukankan      html  css  js  c++  java
  • 【2016-10-25】【坚持学习】【Day12】【WPF】【Telerik】【VirtualtionData 虚拟化数据】

    VirtualQueryableCollectionView 

    When working with the UI components that enable UI Virtualization, you may take advantage of the above mentioned technique by usingVirtualQueryableCollectionView class. It enables you to benefit from the on-demand data loading to smooth scrolling with UI virtual components. 
    The VirtualQueryableCollectionView provides you with the following important members:

      • LoadSize property - defines the maximum number of items requested at once;

      • VirtualItemCount property – defines the total number of items available on the server-side;

      • ItemsLoading event – will be raised when the collection is requesting item at some index and this item is not already loaded. The arguments in this event are as follows:

      • StartIndex – requested item index;

      • ItemCount - number of requested items (can be less than or equal to the LoadSize).

    public MainWindow()
    {
        InitializeComponent();
        var context = new NorthwindEntities();
        var query = context.Order_Details.OrderBy(o => o.OrderID);
        var view = new VirtualQueryableCollectionView(query) { LoadSize = 10 };
        DataContext = view;
    }

    另外一种写法;

     public MainPage()
            {
                InitializeComponent();
    
                var context = new NorthwindDomainContext();
                var query = context.GetOrder_DetailsQuery().OrderBy(o => o.OrderID);
                query.IncludeTotalCount = true;
    
                var view = new VirtualQueryableCollectionView() { LoadSize = 10, VirtualItemCount = 100 };
                view.ItemsLoading += (s, e) =>
                {
                    context.Load<Order_Detail>(query.Skip(e.StartIndex).Take(e.ItemCount)).Completed += (sender, args) =>
                   {
                       var lo = (LoadOperation)sender;
                       if (lo.TotalEntityCount != -1 && lo.TotalEntityCount != view.VirtualItemCount)
                       {
                           view.VirtualItemCount = lo.TotalEntityCount;
                       }
    
                       view.Load(e.StartIndex, lo.Entities);
                   };
                };
    
                DataContext = view;
            }

    作者:zscmj
    出处:http://www.cnblogs.com/zscmj/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    微信端调取相册和摄像头,实现图片上传,并上传到本地服务器
    js 跳转链接的几种方式
    JS 导出表格
    This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed
    错误: 未能完成程序集的安装(hr = 0x8007000b)。探测终止。
    sql server ISNULL失效
    JS 实现加载中转圈效果
    .net core 分页控件X.PagedList.Mvc.Core
    JS 将table内未显示完全内容显示完全
    .net core viewbag 传递list 或 model
  • 原文地址:https://www.cnblogs.com/zscmj/p/5998341.html
Copyright © 2011-2022 走看看