Welcome to the Xceed Community | Help
Community Search  
More Search Options

DataGridColelctionView Replacing Item

Sort Posts: Previous Next
  •  03-23-2009, 9:46 PM Post no. 19547

    DataGridColelctionView Replacing Item

    Hi All

    I have done a few searches for this, and couldn't find any answers, hope someone can help.

    I have the DataGridControl bound to a DataGridCollectionView, the source Collection is an ObservableCollection<T>.  When I replace an item in the source collection by doing this, 'collection[collection.IndexOf(OldItem)] = NewItem;'  the ObservableCollection raises the correct event (NotifyCollectionChangedAction.Replace) but the DataGrid changes the CurrentItem if the CurrentItem was the item that was replaced.

    Is this the correct behavior, if so why? and is there a way around it?

     Many Thanks

  •  03-25-2009, 9:38 AM Post no. 19615 in reply to 19547

    Re: DataGridColelctionView Replacing Item

    Come on, this can't be a hard one to answer.  I'd wouldn't even be worrying about the problem if I could cancel the selection change but I can't because of a Bug in the DataGridCollectionView
  •  03-25-2009, 10:34 AM Post no. 19623 in reply to 19615

    Re: DataGridColelctionView Replacing Item

    First of all, the selection is not controlled by the DataGridCollectionView but by the DataGridControl. The CurrentItem, however, is handled by the DataGridCollectionView.

    In regards to the current item that is being changed during a replace, what happens is that the grid receives a notification to remove the item followed by a notification to add a new item from the DataGridCollectionView (even if in the list only a remove occurs). The result is that the current item is moved and the item is unselected.

    I will add a feature request so that a developer can take a look at the current behavior to see if it can be improved. 


    Senior Technical Writer
    - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  03-25-2009, 5:11 PM Post no. 19654 in reply to 19623

    Re: DataGridColelctionView Replacing Item

    Thanks Jenny.  Any ideas on a work around?  Been thinking too hard about this problem for too long I've probably missed something really obvious.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.