Dear Telerik Support
I just started using your controls for WPF, to see if it suits the needs of our company
Starting by doing basic examples, I stumbled upon the RadGridView pagination
I am trying to use this example
http://demos.telerik.com/silverlight/#DomainDataSource/MVVM and
and this documentation
http://docs.telerik.com/devtools/wpf/controls/raddatapager/getting-started#adding-raddatapager
But it seems my grid wont page if I dont use this
this.view = new QueryableDomainServiceCollectionView<Customer>(context, getCustomersQuery);
this.view.PageSize = 10;
thus attributing the PageSize to it.
right now I use a ObservableCollection<Entity> List.
So my question is: Where how can I use the above mentioned class (QueryableDomainServiceCollectionView) to support my need of pagination?
I don't want to paginate it manually, by using the Unbound mode. and I would prefer to avoid that all data goes into memory
I wish I could attach a zip file of my project. but since I cannot, here is the code (note: you must install the PropertyChanged.Fody nugget in order to run it):
XAML
<Window x:Class="TelerikWpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local="clr-namespace:TelerikWpfApp1"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid Name="grid">
<Grid.DataContext>
<local:ViewModel/>
</Grid.DataContext>
<telerik:RadGridView x:Name="radGridView"
HorizontalAlignment="Left"
Margin="23,30,0,0" VerticalAlignment="Top"
Height="234" Width="468"
ItemsSource="{Binding List}" AutoGenerateColumns="True">
<telerik:RadGridView.Columns>
<telerik:GridViewColumn BindingGroup="{Binding id}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<telerik:RadDataPager x:Name="radDataPager"
Margin="23,264,26,27"
PageSize="5"
DisplayMode="PreviousNext"
Source="{Binding List, ElementName=radGridView}" />
</Grid>
</Window>
XAML.CS
using System.Windows;
namespace TelerikWpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
ViewModel vm = null;
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
vm = grid.DataContext as ViewModel;
vm.Load();
}
}
VIEWMODEL.cs
using PropertyChanged;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace TelerikWpfApp1
{
[ImplementPropertyChanged]
public class ViewModel
{
public ObservableCollection<Entity> List { get; set; }
public void Load()
{
List = GetList().ToObservableCollection();
}
List<Entity> GetList()
{
List<Entity> list = new List<Entity>();
for (int i = 0; i < 100; i++)
{
list.Add(new Entity() { comment = "dasd", id = 1, name = "fefe" });
list.Add(new Entity() { comment = "xxcv", id = 2, name = "dewd" });
list.Add(new Entity() { comment = "zzz", id = 3, name = "jjj" });
}
return list;
}
//public void Save(Entity item, string comment)
//{
// if (item.comment != comment)
// {
// //controller.Save(); }
// }
//}
}
public class Entity
{
public int id { get; set; }
public string name { get; set; }
public string comment { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
public static class ListExtensions
{
public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> items)
{
var c = new ObservableCollection<T>();
foreach (var item in items)
{
c.Add(item);
}
return c;
}
}
}
Thank you!!!!