I’ve made small demo how to create easily endless scrolling of almost 2 mil. records (exact count is 1770607) using RadGridView for WPF.
When you reach the bottom of the vertical scrollbar, more data will be retrieved on-the-fly from the data-base server:
For asynchronous data loading you can use BackgroundWorker:
BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); worker.RunWorkerAsync();
…
void worker_DoWork(object sender, DoWorkEventArgs e) {
NorthwindDataContext context = new NorthwindDataContext(); queryable = from o in context.Orders
from od in context.Order_Details select new { od.OrderID, od.ProductID, od.UnitPrice, od.Quantity, od.Discount, o.CustomerID, o.EmployeeID, o.OrderDate };
}
and on GridViewScrollViewer VerticalScrollEnded event you can get more records:
void ScrollOwner_VerticalScrollEnded(object sender, System.Windows.Controls.Primitives.ScrollEventArgs e) { if (((ScrollBar)e.OriginalSource).Maximum == e.NewValue) { pageSize = pageSize + 50; worker.RunWorkerAsync();
} }
In this demo you can find also how to cancel the default grid sorting and perform your own sorting and how to make nice loading image for your asynchronous operations.
Enjoy!
[Download]
Vladimir Enchev is Director of Engineering, Native Mobile UI & Frameworks