// 写数据到文件 public async Task WriteMenuCardAsync(MenuCard menuCard) { StorageFolder folder = ApplicationData.Current.RoamingFolder; if (menuCard.IsDirty) { StorageFile storageFile = await folder.CreateFileAsync( string.Format("MenuCards{0}.xml", menuCard.Title), CreationCollisionOption.ReplaceExisting); await WriteMenuCardToFileAsync(menuCard, storageFile); menuCard.ClearDirty(); } }
public MenuCard ToMenuCard() { var menuCard = new MenuCard { Title = this.Title, Description = this.Description, ImagePath = this.ImagePath }; foreach (MenuItemData item in this.MenuItems) { menuCard.MenuItems.Add(item.ToMenuItem()); } menuCard.ClearDirty(); return menuCard; }