The new DomainCollectionView and RadGridView

9 posts, 2 answers
  1. Tomas
    Tomas avatar
    92 posts
    Member since:
    Jun 2010

    Posted 03 Dec 2010 Link to this post


    The WCF RIA Services team released a new toolkit on 2 December, which included a MVVM friendly collection that supports server side paging, filtering and grouping. With the sdk datagrid it works as intended but with RadGridView it crashes with the following stack trace:

    at System.Windows.Data.CollectionView.VerifyRefreshNotDeferred()
    at System.Windows.Data.CollectionView.get_CurrentItem()
    at Microsoft.Windows.Data.DomainServices.CollectionViewWrapper.get_CurrentItem()
    at Telerik.Windows.Data.DataItemCollection.UpdateCurrentItemFromSourceCollection()
    at Telerik.Windows.Data.DataItemCollection.HandleCurrentItemChangeOfSourceCollectionView(Object sender, EventArgs args)
    at Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.EventArgs>.ReceiveWeakEvent(Object sender, EventArgs args)
    at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
    at Microsoft.Windows.Data.DomainServices.CollectionViewWrapper.OnPageChanged(EventArgs e)
    at Microsoft.Windows.Data.DomainServices.CollectionViewWrapper.OnPagedCollectionViewPageChanged(Object sender, EventArgs e)
    at Microsoft.Windows.Data.DomainServices.PagedCollectionViewBase.OnPageChanged(EventArgs e)
    at Microsoft.Windows.Data.DomainServices.PagedCollectionViewBase.EndMoveToPage(Int32 pageIndex)
    at Microsoft.Windows.Data.DomainServices.DomainCollectionView.DomainPagedCollectionView.CompleteMoveToPage(Int32 pageIndex)
    at Microsoft.Windows.Data.DomainServices.DomainCollectionView.SyncToCurrentValues()
    at Microsoft.Windows.Data.DomainServices.DomainCollectionView.OnLoadCompleted(Object sender, AsyncCompletedEventArgs e)
    at Microsoft.Windows.Data.DomainServices.CollectionViewLoader.OnLoadCompleted(AsyncCompletedEventArgs e)
    at Microsoft.Windows.Data.DomainServices.DomainCollectionViewLoader.OnLoadCompleted(Object sender, EventArgs e)
    at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Object result)
    at System.ServiceModel.DomainServices.Client.LoadOperation.Complete(DomainClientResult result)
    at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
    at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.<Load>b__17(Object )

    A example solution can be found in the following blogpost:
    Just switch the sdk datagrid to a RadGridView and running the application causes it to instantly crashes.

  2. Rossen Hristov
    Rossen Hristov avatar
    2477 posts

    Posted 03 Dec 2010 Link to this post

    Hello Tomas,

    Have in mind that this toolkit is still in CTP. Nevertheless, we will investigate this issue immediately. Thank you for reporting it. We will let you know what is going on when we find out.

    At first glance it seems that MS have made a breaking change and they are raising the PageChanged event while their collection is still inside the DeferRefresh. When the page is changed, we want to sync the current item and we ask the collection to give it to us but it slams us because it is still inside a DeferRefresh. Very weird.

    We will investigate how this can be resolved.

    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. Answer
    Kyle avatar
    1 posts
    Member since:
    Dec 2010

    Posted 07 Dec 2010 Link to this post

    This is probably an error in the DomainCollectionView in the December 2010 Toolkit. It seems like a reasonable expectation to be able to access the CurrentItem when a PageChanged event is raised. Until the next toolkit release, this workaround will allow you to use the DCV with the Telerik RadGridView. Just use the DCVW in place of the DCV.

    private class DomainCollectionViewWorkaround<TItem> : DomainCollectionView<TItem>
        private bool _suppressDefer;
        public DomainCollectionViewWorkaround(CollectionViewLoader collectionViewLoader, IEnumerable<TItem> source)
            : base(collectionViewLoader, source)
        public override IDisposable DeferRefresh()
            return this._suppressDefer ? new NoDefer() : base.DeferRefresh();
        protected override void OnLoadCompleted(object sender, AsyncCompletedEventArgs e)
            this._suppressDefer = true;
            base.OnLoadCompleted(sender, e);
            this._suppressDefer = false;
        private class NoDefer : IDisposable
            public void Dispose()
                // do nothing
  4. Answer
    Milan avatar
    1989 posts

    Posted 15 Dec 2010 Link to this post

    Hi Kyle,

    We did investigate this issue further and we identified a problem in our code which we will be fixing. You can track the status of this issue from here.

    Thank you for reporting this issue. I have updated your Telerik points.

    Best wishes,
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  5. Tomas
    Tomas avatar
    92 posts
    Member since:
    Jun 2010

    Posted 11 Jan 2011 Link to this post

    Thank you both Telerik and Microsoft for your support.
    We've decided to wait and see what future versions from either company has to offer.


  6. Richard
    Richard avatar
    7 posts
    Member since:
    Sep 2008

    Posted 02 Feb 2011 Link to this post

    I clicked on the link to see what the status of this issue is, but it does not take me to the particular bug report in PITS. Has this been resolved?
    If not, how can I track it in PITS?

  7. Vlad
    Vlad avatar
    11100 posts

    Posted 08 Feb 2011 Link to this post


     The issue is still not resolved and it was set to private. I've changed the issue to be public - here is the link:

    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  8. Sergey
    Sergey avatar
    1 posts
    Member since:
    Aug 2010

    Posted 10 Feb 2011 Link to this post

    RadGridView does not work with DomainCollectionView and  DomainCollectionViewWorkaround.

    How to reproduce the bug.

    1. Take the following samples:


    2. Apply the following changes to DomainCollectionViewSample to view/test bug in RadGridView  + RadGridView + DomainCollectionViewWorkaround:

    2.2 In client project "DomainCollectionViewSample":
     2.2.1 Add to the project the class DomainCollectionViewWorkaround.cs;
     2.2.2 Add reference to Telerk.Windows.Controls.GridView;
     2.2.3 In MainPage.xaml - change  sdk:GridView to telerik:RadGridView;
     2.2.4 In SampleViewModel.cs - change "this._view = new DomainCollectionView<SampleEntity>(this._loader, this._source);"  to "this._view = new DomainCollectionViewWorkaround<SampleEntity>(this._loader, this._source);"

    3. Rebuild "DomainCollectionViewSample" solution;

    4.Run app;
     4.1. Switch RadGridView to 2-nd page;
     4.2. Try to sort RadGridView clicking any column header - app will go into endless cycle (set breakpoint in DomainCollectionViewWorkaround.OnLoadCompleted() method.)

  9. Adrian Pay
    Adrian Pay avatar
    28 posts
    Member since:
    Nov 2009

    Posted 09 Apr 2012 Link to this post

    How is this problem going, looks like I am facing the same issue now.

    Does Kyle's workaround really work?  thanks
Back to Top