Reputation: 3943
Working under MVVM pattern
T
is a class, from my edmx file (entity framework).
O
is an ObservableCollection<T>
.
O
is populated with all T
from database.
Then, some fields of T
, are edited by the user from the GUI.
How can I fire this event?
I don't want to edit my edmx file, I prefer to keep it like it was generated. So, this means I can't use something like this, because I should modify my model, implementing INotifyPropertyChanged
.
Upvotes: 0
Views: 61
Reputation: 6693
I don't think you should interact with model objects from your EDMX directly in the view (GUI). Create a view-model to wrap your model class T
, have your new view-model implement INotifyPropertyChanged
, and use that in the ObservableCollection
. Pass in the model object when creating your view-model. When a property is changed on the view-model, update the model object and fire off the PropertyChanged
event (I'm using YourEdmxClass
in place of T
because T
is often used with generics):
public class YourEdmxClassViewModel : ViewModel
{
private YourEdmxClass model;
public YourEdmxClassViewModel(YourEdmxClass model)
{
this.model = model;
}
public int SomeProperty
{
get { return this.model.SomeProperty; }
set
{
this.model.SomeProperty = value;
this.RaisePropertyChanged(() => this.SomeProperty);
}
}
}
Upvotes: 1