2

i'm new by programming in wpf and c#. I have a litte problem with an datagrid. The grid is binding on a EF-Table.

I can see and change all fields and save the changes to the database. The problem is. When i save the data via context.savechanges to the SQL-Database, the Trigger on the SQL-Server-Table modified some fields in the record.

When is Reload the Entity for the currentItem after the save-command, i can see the modified data in my Entity but not in my UI. I must make a datagrid.items.refresh to see the changes. But the refresh is not performant and i loose the current cell position. I need a way, to push any changes from SQL-Server on the current record on the fly to the UI after change on field in the UI.

Have anybody some ideas?

In an simpel TextBox-Element on a Window, i can use the BindingExpression to push the changes via binding.UpdateTarget. But it's not possible in DatagridTextColumn.

1 Answers1

0

Your entity class should implement the INotifyPropertyChanged interface and raise change notications whenever a data-bound property is set to a new value.

If you are using auto-generated entity classes, you need to modify the template that these are generated from:

How to get property change notifications with EF 4.x DbContext generator

Or you can bind to your own wrapper classes that do implement this interface:

Implement INotifyPropertyChanged on generated Entity Framework classes

mm8
  • 163,881
  • 10
  • 57
  • 88