Ответ 1
Я проверил ваш код. И у меня вопрос к этому. Я просмотрел страницу MSDN, которую вы предоставили. И там я вижу пример добавления задачи:
private void AddTask(object sender, RoutedEventArgs e)
{
//....
//Mostly the same code as your
JumpList jumpList1 = JumpList.GetJumpList(App.Current);
jumpList1.JumpItems.Add(jumpTask1); // It is absent in your code!!!
JumpList.AddToRecentCategory(jumpTask1);
jumpList1.Apply();
}
Я создал два своих метода Create
и Extract
, и я могу получить доступ к созданным во время текущей задачи сеанса. Это мой код:
private void Extract()
{
var jumpList = JumpList.GetJumpList(Application.Current);
if (jumpList == null) return;
foreach (var item in jumpList.JumpItems)
{
if(item is JumpTask)
{
var jumpTask = (JumpTask)item;
Debug.WriteLine(jumpTask.Title);
}
}
}
private void Create() {
var jumpList = JumpList.GetJumpList(Application.Current);
if (jumpList == null)
{
jumpList = new JumpList();
JumpList.SetJumpList(Application.Current, jumpList);
}
string title = "Title";
string programLocation = "Location";
var path = "path";
var jt = new JumpTask
{
ApplicationPath = programLocation,
Arguments = path,
Description = path,
IconResourcePath = programLocation,
Title = title
};
jumpList.JumpItems.Add(jt);
JumpList.AddToRecentCategory(jt);
jumpList.Apply();
}
Я не уверен, что это ответ на ваш вопрос, но я ищу причину, почему вы не добавляете свою задачу в JumpItems список?