Binding does not update for DataGrid in Entity Framework 4

I am using Entity Framework 4 / WPF / C #. new ObservableCollection<Entity>(context.EntitySet)bound to WPF DataGrid in XAML. It works great. But when I programmatically create a new Entity and add it to the context, the DataGrid remains unchanged. What should I do to update a DataGrid?

+3
source share
4 answers

You do not see the update, because it ObservableCollection<T>receives these values ​​from the object installed once during construction. All additional changes to the set of objects are not respected.

Only calls ObservableCollection<T>.Add(and others) generate events CollectionChanged.

+2
source

, context.EntitySet ObservableCollection. .EntitySet .

, EntitySet? ObservableCollection ?

+1

Silverlight, , RIA. ? .AddTo {EntitySetName]() . {EntitySetNme}.Add()

, , - . , . (-), UI .

0

;) datagrid , ? datagrid , .

therefore, if you add an item to your context, simply call OnPropertyChanged ("YourEntityCollectionPropertyHere") for your collection property.

0
source

All Articles