public static async Task CreateDefaultList(bool clear = false) { if (JumpList.IsSupported()) { var jumplist = await JumpList.LoadCurrentAsync(); if (!jumplist.Items.Any() || clear) { jumplist.Items.Clear(); var args = new ToastNotificationArgs() { type = "jumplist", openBookmarks = true }; var item = JumpListItem.CreateWithArguments(JsonConvert.SerializeObject(args), "Open Bookmarks"); item.Logo = new Uri("ms-appx:///Assets/BadgeLogo.scale-100.png"); args.openBookmarks = false; args.openPrivateMessages = true; var item2 = JumpListItem.CreateWithArguments(JsonConvert.SerializeObject(args), "Open Private Messages"); item2.Logo = new Uri("ms-appx:///Assets/BadgeLogo.scale-100.png"); jumplist.Items.Add(item); jumplist.Items.Add(item2); var seperate = JumpListItem.CreateSeparator(); jumplist.Items.Add(seperate); await jumplist.SaveAsync(); } } }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { if (JumpList.IsSupported()) { var list = await JumpList.LoadCurrentAsync(); list.Items.Clear();//建议每次在添加之前清除掉原先已经存在的数据 list.Items.Add(JumpListItem.CreateSeparator()); new List <JumpListItem>() { //CreateJumpListItem("feed","动态","页面",new Uri("ms-appx:///Assets/facebook.png")), //CreateJumpListItem("notification","通知","页面",new Uri("ms-appx:///Assets/github.png")), CreateJumpListItem("test", "打开测试页面", "测试", new Uri("ms-appx:///Assets/Icons/ic_settings_white_24dp.png")), //CreateJumpListItem("settings","设置","页面",new Uri("ms-appx:///Assets/Icons/ic_settings_white_24dp.png")) }.ForEach((item) => { list.Items.Add(item); }); await list.SaveAsync(); } }