I'm starting to use MVVM,but I've been confused about something,there's my problem,I wanna add just one row in my table,and here's the way that i do this:
Viewmodel class:
// Model.MyClass is my entity
Model.MyClass myClass;
public Model.MyClass MyClass
{
get
{
return myClass;
}
set
{
myClass= value;
base.OnPropertyChanged(() => MyClass);
}
}
context = new myEntities();
myclass=new Model.MyClass();
context.MyClass.AddObject(MyClass);
Then:
public ICommand SaveCommand
{
get { return new BaseCommand(Save); }
}
void Save()
{
if (DefaultSpecItem != null)
{
context.SaveChanges();
}
}
and i bind the datatatemplate to MyClass,it works prefectly and savechanges to my database,but don't update my view,in this case i want to return the id,so i put a textbox and bind it to id(prpoerty), what's the problem?am i missing something? i would appretiate any helps.