Say I have ViewModel class MyViewModel like:
public class MyViewModel : ViewModelBase
{
private Person _person;
public Person Person
{
get { return _person; }
set
{
if (this._person != value)
{
this._person = value;
this.RaisePropertyChanged("Person");
}
}
}
private AddNew(){
this = new MyViewMode(new Person());
}
}
What I want is try to create new instance inside this view mode in method AddNew(). When this VM bind to UI, I want to user can to change the viewmodel for new entity without change UI.
But I can't do that because code this = new MyViewMode(new Person()); won't work.
How to resolve this problem?