How to add Tasks to Jumplists in .NET 4.0 and Windows 7
Introduction
Windows 7 provides a new taskbar feature for applications called jumplists. They appear, when you right-click on a application icon in the taskbar. By default you see a list of recent files opened and two entries to launch and detach the application.
.NET 4.0 provides a managed API that allows you to easily manipulate the entries in the jumplist.
How to add a Task to the Jumplist
A jumplist is nothing more than a categorizes list of links to files that can be launched by the user. The links are called JumpTasks
. They can be parametrized with a title, description, icon, filepath and command line arguments.
In the following sample I create a new JumpList
and add a task to the list that launches the sample application, but with a command line argument. If the application is launched with an argument, it shows a MessageBox instead.
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
if (e.Args.Count() > 0)
{
MessageBox.Show("You have the latest version.");
Shutdown();
}
JumpTask task = new JumpTask
{
Title = "Check for Updates",
Arguments = "/update",
Description = "Cheks for Software Updates",
CustomCategory = "Actions",
IconResourcePath = Assembly.GetEntryAssembly().CodeBase,
ApplicationPath = Assembly.GetEntryAssembly().CodeBase
};
JumpList jumpList = new JumpList();
jumpList.JumpItems.Add(task);
jumpList.ShowFrequentCategory = false;
jumpList.ShowRecentCategory = false;
JumpList.SetJumpList(Application.Current, jumpList);
}
}
Last modified: 2009-12-16 13:50:20
Copyright (c) by Christian Moser, 2011.
Comments on this article
|
Andira Muttakim |
|
|
Commented on 27.January 2010 |
is there only work in WPF? how about Form? |
|
|
|
Andira Muttakim |
|
|
Commented on 27.January 2010 |
is there only work in WPF? how about Form? |
|
|
|
Mario Fraiß |
|
|
Commented on 28.March 2010 |
It does also work in Windows Forms under a .NET 4.x and Win7 environment. |
|
|
|
Martin |
|
|
Commented on 17.May 2010 |
Any way you can implement this to standard run time?
e.g. Have a command on the list (Red) that changes the background color of the form to Red? |
|
|
|
K |
|
|
Commented on 25.June 2010 |
can jumplist support custom event like just calling a method inside the owner |
|