Changing instances of Itemsource within DataGrid

Jul 22, 2009 at 8:02 AM


We are currently trying to implement a save mechanism for our Data. We have very large Itemssource, because of this we do not save the whole set. It would take too much time to send it to the server and get it back. Therefore we are trying to save single instances. The instance that should be saved is send to the server and we get back a new instance. In a demo project we simulated this:

            // save and get the new instance
            Test.DataObject newObj = new Test.DataObject() { Id = 2, Name = "Data2", Description = "DataDesc2", Timestamp = Environment.TickCount };
            // chnaging the third instance within the itemssource collection of the grid
            viewModel.Data[2] = newObj;

The Problem with this is that at the moment we change the instance the selection state is screwed up. The MultiSelektor is trying to remove the  old insance and not adding a new instance.
Because of this the row we saved is still selected but not correctly. In fact it is only visually selected, but not contained in the selecteditems.
What can we do to get the right new instance selected after the save?