Updating DataSet

Jan 21, 2009 at 7:40 AM
Hello,

I'm using v1. Datagrid and have a column:

   <my:DataGridTemplateColumn Header="Home Phone">
       <my:DataGridTemplateColumn.CellEditingTemplate>
           <DataTemplate>
               <local:MaskedTextBox InputMask="+7 (iii) iii-ii-ii" Text="{Binding HomePhone, Mode=TwoWay}" />
           </DataTemplate>
       </my:DataGridTemplateColumn.CellEditingTemplate>
       <my:DataGridTemplateColumn.CellTemplate>
           <DataTemplate>
               <TextBlock Text="{Binding HomePhone}" VerticalAlignment="Center" HorizontalAlignment="Center" />
           </DataTemplate>
       </my:DataGridTemplateColumn.CellTemplate>
   </my:DataGridTemplateColumn>

When I launch an application it work perfectly, except that I need press Enter in edit mode to commit changes in cells. How to commit them when cell or row losing focus?

I use an EF query as ItemsSource
Coordinator
Jan 21, 2009 at 1:08 PM
"How to commit them when cell or row losing focus?"

When the cell or row loses focus, it is not commiting?  Does pressing 'tab' work?
Jan 21, 2009 at 4:10 PM
Hi,

I have just published a blog post about committing changes as the focus moves from one cell to the next:

http://www.scottlogic.co.uk/blog/wpf/2009/01/wpf-datagrid-committing-changes-cell-by-cell/

Regards,
Colin E.
--
http://www.scottlogic.co.uk/blog/wpf/ - my WPF blog
http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx - WPF DataGrid Practical Examples
Jan 22, 2009 at 5:24 AM
2 vinsibal:
I have complicate query for selecting items, so I need custom logic for update. Because of that, I hook up to RowEditEnding event where I post changes to database.
If I pressed 'Enter' or 'Tab' (as you advice) then all changes in controls reflected in entity, otherwise - no.

2 ColinEber:
Thanks, nice post.