public PlanetDetailViewModel(SolPlanet p, INavigation nav) : base(nav) { //Keep a reference to the original _original = p; //Make an indepednent copy Model = new SolPlanet(p); //Commands SaveCommand = new Command(execute: () => { //Note if the group needs changing bool hasMovedGroup = (_original.Explored != Model.Explored); //Update the original planet data (mutable reference type) _original.Copy(Model); //Message back if the group has changed if (hasMovedGroup) { MessagingCenter.Send(this, "PlanetUpdated", _original); } //Navigate back _ = Navigation.PopAsync(); }); }
//Overwrite the original private void Save() => _original.Copy(Model);