Exemplo n.º 1
0
        public TasksViewModel()
        {
            Title             = "Tasks";
            UserTasks         = new ObservableCollection <UserTask>();
            LoadItemsCommand  = new Command(async() => ExecuteLoadItemsCommand());
            EditItemCommand   = new Command(async(item) => await EditItem(item));
            DeleteItemCommand = new Command((item) => DeleteItem(item));

            MessagingCenter.Subscribe <NewTaskPageViewModel, UserTask>(this, AppMessages.SaveUserTaskMessage, async(obj, item) =>
            {
                var _item = item as UserTask;
                if (item != null)
                {
                    bool result = await AppService.AddNewUserTask(_item);
                    if (result)
                    {
                        UserTasks = new ObservableCollection <UserTask>(AppService.UserTasks);
                    }
                }
            });
        }