Beispiel #1
0
        public EditSpellListPageViewModel(IViewServices viewSvc, ISpellList spellList)
            : base(spellList)
        {
            _title = spellList.Title;
            _class = spellList.Class;
            _level = spellList.Level;

            PickSpellListCommand = new Command(() =>
            {
                spellList.Title = _title;
                spellList.Class = _class;
                spellList.Level = _level;
                Services.MockDataStore.Instance.Save(spellList);
                viewSvc.Navigation.PushAsync(new Views.PickSpellListPage(spellList));
            });

            DeleteSpellListCommand = new Command(async() =>
            {
                if (await viewSvc.DisplayAlert("Delete Spell List",
                                               $"Are you sure you want to delete \"{Title}\"?", "Yes", "No"))
                {
                    Services.MockDataStore.Instance.Delete(SpellList);
                    await viewSvc.Navigation.PopToRootAsync();
                }
            });

            CloneSpellListCommand = new Command(() =>
                                                viewSvc.Navigation.PushAsync(new Views.EditSpellListPage(SpellList.Clone())));
        }