Manual edit object in Datagrid itemcollection

Dec 8, 2008 at 7:18 PM

Hi
What is best practice for manual edit object in itemcollection when using Datagrid. The Datagrid itemsource is bound to collection of IEnumerable.
I try to use 
ICollectionView view = CollectionViewSource.GetDefaultView(dgOrderLine.Items);
IEditableCollectionView iecv = (IEditableCollectionView)view;
iecv.EditItem(row);

 

but I dont get the object to edit. For instance (iecv.FirstName = "Sara", iecv.Amount = iecv.Price * iecvNumber) or somthing like that. The result must be visible in grid, and trigg the propertychange in underlying datasource.

Kindly help

Coordinator
Dec 9, 2008 at 1:43 PM
It seems like you want to do it through the UI but update the data source?  If you want to programmatically edit a cell/row and make it visible through the UI, you should call DataGrid.BeginEdit().  If you do that and want to somewhat mirror how someone typing would edit, then you will have to change the content of the cell as opposed to updating the underlying data source (like you have described above).
Dec 10, 2008 at 10:01 AM
Edited Dec 10, 2008 at 10:04 AM
Thanks for replay

I think I have solve the problem, the way is: take out the row from IEditableCollectionView and change the current object. It looks like it work, my content in row is visible and the contet can be updated in the underlying datasource.