/// <summary> /// 删除一张报纸 /// </summary> /// <param name="newsPaper">要删除的报纸</param> static async public Task DeleteNewsPaper(NewsPaper newsPaper) { OnPaperDeleting?.Invoke(newsPaper); var paperListinFile = await ReadListFromFile(); //var index = paperListinFile.IndexOf(newsPaper.newsPaperModel); paperListinFile.Remove(newsPaper.newsPaperModel); NewsPapers.Remove(newsPaper); //3、将paperListinFile重新保存到文件中 await FileIO.WriteBytesAsync(paperListFile, App.ObjectToByteArray(paperListinFile)); OnPaperDeleted?.Invoke(newsPaper); }
private void NewsPaper_OnPaperDeleted(NewsPaper newsPaper) { NewsPapers.Remove(newsPaper); paperNavigationView.SelectedItem = NewsPapers.First(); }