silverlight - How do you refresh your ViewModel when navigating back using MVVM -


when navigating using button on phone how can refresh viewmodel?

i'm using button on phone believe same calling navigationservice.goback(), navigates previous page on stack constructor not called in view or viewmodel.

you can hook in base page class onnavigatingto event , call method on viewmodel. don't have vs me pseudo-code be:

in mybasepage : page

public void onnavigatingto(object sender, eventargs e) {    var vm = this.datacontext baseviewmodel;    if(vm != null)    {       vm.initialize();    }  } 

you can same before leaving page:

public void onnavigatingfrom(object sender, eventargs e) {    var vm = this.datacontext baseviewmodel;    if(vm != null)    {       vm.save();    }  } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -