I'm populating a jumplist via:
public static void AddToList(String path)
{
var jumpList = JumpList.GetJumpList(Application.Current);
if (jumpList == null) return;
string title = System.IO.Path.GetFileName(path);
string programLocation = Assembly.GetCallingAssembly().Location;
var jt = new JumpTask
{
ApplicationPath = programLocation,
Arguments = path,
Description = path,
IconResourcePath = programLocation,
Title = title
};
JumpList.AddToRecentCategory(jt);
jumpList.Apply();
}
Which works great. The only problem is that I also have a file menu in my application and would like to show the recent list there as well. I could do it easily by storing a second copy of the recent files, but I was wondering if I could possibly enumerate the list of files used by the jumplist. I haven't been able to figure out anything for doing so.
Am I missing something here? Can I enumerate the files in the jumplist, or do I need to store my own duplicate list?
I have checked your code. And I have the question to it. I looked into MSDN page that you provided. And there I see example of adding task:
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();
}
I have created two my own methods Create
and Extract
and I can access to created during current session task at least. This is my code:
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();
}
I am not sure that this is answer on your question, but I am looking to reason why you don't add your task to JumpItems list?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With