title: Implementing Telerik VirtualQueryableCollectionView with MVVM pattern
body: <p>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:</p>
  
  <pre><code>public PricingView(PricingViewModel vm)
  {
      InitializeComponent();
  
      var dataView = new VirtualQueryableCollectionView()
                           { LoadSize=20, VirtualItemCount = vm.Prices.Count };
      dataView.ItemsLoading += (sender, e) =&gt;
          {
              var view = sender as VirtualQueryableCollectionView;
              if (dataView != null)
              {
                  view.Load(e.StartIndex, vm.Prices.Skip(e.StartIndex).Take(e.ItemCount));
              }
          };
      this.PricesGridView.ItemsSource = dataView;
  }
  </code></pre>
  
  <p>Since this code only deals with UI specific functionality and it is specific the the view implementation, I am comfortable that this code belongs in the code-behind rather than the ViewModel as it would be a departure from ther MVVM pattern to put a reference to VirtualQueryableCollectionView in the ViewModel.  The part that I am not happy with is passing the reference to the ViewModel into the constructor of the View.  Is there a good way to get the reference in the code-behind without having to pass the reference in the constructor?</p>
  
  <p>Or is there a better way to do all of this?</p>