wpf - What is the usage of IEditableObject with DataGrid? -


here's excerpt http://blogs.msdn.com/b/vinsibal/archive/2009/04/07/5-random-gotchas-with-the-wpf-datagrid.aspx:

5.data source items should implement ieditableobject transactional editing functionality.

if not familiar ieditableobject, see msdn article has explanation , code sample. datagrid has baked in functionality transactional editing via ieditableobject interface. when begin editing cell, datagrid gets cell editing mode row editing mode. means can cancel/commit cells cancel/commit rows. example, edit cell 0 , press tab next cell. cell 0 committed when pressing tab. start typing in cell 1 , realize want cancel operation. press ‘esc’ reverts cell 1. realize want cancel whole operation press ‘esc’ again , cell 0 reverted original value.

i same transactional behavior without implementing ieditableobject. missing?

  public class person {     public string firstname { get; set; }     public string lastname { get; set; }     public string description { get; set; }   }    people = new list<person> {     new person(){firstname = "fname", lastname = "lname", description = "description"}   };    <datagrid itemssource="{binding path=people}" /> 

of course doesn't matter simple string in memory. there uses ieditableobject.
example, imagine want store every edited record database. want commit changes in 1 transaction, in endedit(). similar uses can found other interface methods.

also, not directly editing bound object. ieditableobject instance might hold variable of type wich actual data source. not apply edited values until endedit() called in case, , canceledit() restore values original data source.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -