/// <summary> /// 删除todo /// </summary> /// <param name="id">ID</param> /// <returns></returns> /// 先从列表删除,然后把列表内容都序列化保存,接着: /// 1.如果已经登陆的,尝试发送请求; /// 2.离线模式,不用管 private async Task DeleteToDo(string id) { try { var itemToDeleted = MyToDos.ToList().Find(s => { if (s.ID == id) { return(true); } else { return(false); } }); DeletedToDos.Add(itemToDeleted); await SerializerHelper.SerializerToJson <ObservableCollection <ToDo> >(DeletedToDos, SerializerFileNames.DeletedFileName, true); MyToDos.Remove(itemToDeleted); UpdateDisplayList(SelectedCate); await SerializerHelper.SerializerToJson <ObservableCollection <ToDo> >(MyToDos, SerializerFileNames.ToDoFileName, true); if (!App.isInOfflineMode) { var result = await PostHelper.DeleteSchedule(id); await PostHelper.SetMyOrder(LocalSettingHelper.GetValue("sid"), ToDo.GetCurrentOrderString(MyToDos)); } Messenger.Default.Send(new GenericMessage <ObservableCollection <ToDo> >(MyToDos), MessengerTokens.UpdateTile); } catch (Exception e) { var task = ExceptionHelper.WriteRecord(e); } }