This is a migrated thread and some comments may be shown as answers.

[Solved] VirtualQueryableCollectionView with MVVM

1 Answer 150 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jim
Top achievements
Rank 1
Jim asked on 01 Aug 2011, 12:31 PM

I have an application that was implemented using the Telerik RadGridView control and Caliburn.Micro MVVM framework. Because of some performance problems, I needed to implement the Telerik VirtualQueryableCollectionView in place of the direct control-to-ObservableCollection binding that was being used. The original code has the ItemsSouce property of the RadGridView was bound to the Prices property of the view model. I had to eliminate that binding and this in the code-behind:

public PricingView(PricingViewModel vm) 

    InitializeComponent(); 
    var dataView = new VirtualQueryableCollectionView() 
                         { LoadSize=20, VirtualItemCount = vm.Prices.Count }; 
    dataView.ItemsLoading += (sender, e) => 
        { 
            var view = sender as VirtualQueryableCollectionView; 
            if (dataView != null) 
            { 
                view.Load(e.StartIndex, vm.Prices.Skip(e.StartIndex).Take(e.ItemCount)); 
            } 
        }; 
    this.PricesGridView.ItemsSource = dataView; 




The biggest problem with this is the parameter that is required in the constructor.  Is there a better way to get a reference
 to the ViewModel? Or perhaps a better way to do the whole thing?
Thanks

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 04 Aug 2011, 01:22 PM
Hi,

You can move this code in your view model - VirtualQueryableCollectionView property. You can also create more properties for every parameter and two way bind them.

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
GridView
Asked by
Jim
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or