silverlight - Implementing Telerik VirtualQueryableCollectionView with MVVM pattern -
i have application implemented using telerik radgridview control , caliburn.micro mvvm framework. because of performance problems, needed implement telerik virtualqueryablecollectionview in place of direct control-to-observablecollection binding being used. original code has itemssouce property of radgridview bound prices property of view model. had eliminate binding , in code-behind:
public pricingview(pricingviewmodel vm) { initializecomponent(); var dataview = new virtualqueryablecollectionview() { loadsize=20, virtualitemcount = vm.prices.count }; dataview.itemsloading += (sender, e) => { var view = sender virtualqueryablecollectionview; if (dataview != null) { view.load(e.startindex, vm.prices.skip(e.startindex).take(e.itemcount)); } }; this.pricesgridview.itemssource = dataview; }
since code deals ui specific functionality , specific the view implementation, comfortable code belongs in code-behind rather viewmodel departure ther mvvm pattern put reference virtualqueryablecollectionview in viewmodel. part not happy passing reference viewmodel constructor of view. there way reference in code-behind without having pass reference in constructor?
or there better way of this?
my application implemented mvvm light, in case used virtualqueryablecollectionview
class in viewmodel instead view.
i did because think class similar observablecollection
although not part of core classes. actually, virtualqueryablecollectionview
not limited telerik controls many other standard controls listview
.
the fetch in case implemented in model.
void mainviewmodel() { this.traces = new virtualqueryablecollectionview<myentityclass>() { // viewmodel manages loadsize loadsize = this.pagesize, virtualitemcount = mymodel.totalcount }; this.traces.itemsloading += (s, args) => { this.traces.load(args.startindex, mymodel.fetchrange(args.startindex, args.itemcount)); }; }
Comments
Post a Comment