I have an MVVM project in which the main view ("View1") has a button called Save and listbox control which has binding of model emp.
The viewmodel (ViewModel1) implements inotifypropertychanged and it has SavedButtonCommand binding to Save button of View1 and saves the record to SavedEMp.In View1 there is a button "Next" which takes to the "View2" page.View2 page has ViewModel2 which has SaveAgain button .And viewmodel2 has a binding to the SaveAgainButtonCommand and it also saves the record to the localdb called SavedEmp of emp records.
View1 listbox gets refreshed when the statement RaisePropertyChanged("SavedEmpDataSoruce") gets executed and the observablecollection "SavedEmpDataSoruce" is binding to this listbox.Since these two are in View1 after the save button whenenever the statement RaisePropertyChanged("SavedEmpDataSoruce") gets executed it is refreshing the data.
But when user comes back from View2 to View1 the listbox in View1 is not refreshed with the data of View2 saved emp record.
private ObservableCollection<Emp> _SavedEmp;
public ObservableCollection<Emp> SavedEmp
{
get
{
if(_SavedEmp == null)
{
_SavedEmp = Emp.GetSavedEmps();
}
return _SavedEmp;
}
set
{
this._SavedEmp = value;
RaisePropertyChanged("SavedEmp");
}
}
Is there a way we can refresh the listbox data when moved from View2 to View1 again ?