Hi
My colleague and I want to create an application with some pages, where the user is allowed to change some settings. These settingspages do not have savebuttons. There is a main settingspage and two child settingspages. The settings should be persisted if the user navigates back from one of the three pages or the user makes some changes in one of the child pages.
The model is loaded in the OnAppearing() Method of the main settingspage. So we can not use OnDisappearing() Method of the childpages to save the model, because the sequence of these methods and Pushed() and Popped() of the navigationpage differs on each platform: forums.xamarin.com/discussion/21417/navigationpage-push-pop-event-sequence-different-across-platforms
Our solution at this time is to save the model in the setters of the properties of the childpages viewmodels. But that could not be best practise. So our question is: Are there any other solutions to solve this problem? What are the best practises for that problem?
Code:
public ReminderRepetitive ListViewSelectedItem
{
get { return _settingsEntity.ReminderRepetitive; }
set
{
if (!Equals(_settingsEntity.ReminderRepetitive, value))
{
_settingsEntity.ReminderRepetitive = value;
OnPropertyChanged("ListViewSelectedItem");
Save();
_navigation.PopAsync();
}
}
}
public void Save()
{
_businessLayer.UpdateSettings(_settingsEntity);
}