Windows 7 Taskbar Jumplist takes you right to your favorite applications or frequent files related to your application running in the task bar.
To open a Jump List, just right-click a program icon on the Windows 7 taskbar and the Jumplist pops up.
If you look in MSDN for the WPF 4 JumpList class you’ll see a very nice code snippet which creates Jumplist tasks but uses an external DLL as the source of the tasks icons.
First you should know that the WPF 4 JumpList is only a managed wrapper around the Windows 7 Jumplist Native APIs, and the only option to display an icon is to have an icon as native resource.
By default, working with WPF or .NET application you don’t really have a native resource, only a managed one.
Surprisingly a .NET application can have a native resource. Lets see how to create one with icon, combine it with our .NET/WPF application and then use it as our Jumplist Task source.
To add a native resource
- In VS2010 open the File menu –> New –> File.
- Select the “Native Resource Template” and click Open.
- In the opened tab, right click on the ResTemplX.rct folder icon and select ‘”Add Resource…”.
- In the opened dialog pick “Icon” and select “New” to create new one or “Import…” to import existing one.
- Save the resource file (CTRL+S), as “32-bit Resource file” type (open the combo-box at the bottom) in your project folder.
- Open your project properties page, in the “Application” section click on the “Resource file” radio-button and pick the file you’ve just saved.
- Build your project.
You’ve just set your project to work with a native resource file (Side effect: your application icon will be picked from there).
Next you should pick the desired icon in your Jumplist task.
- To create a Jumplist, open the App.xaml and add the following (not as resource):
- Run the application, open its Jumplist and you should see your icon.
Note: you can also set the JumpTask.IconResourceIndex (which is zero by default) to a different value for picking a different icon index located in the same resource file.
Now the question is why would you like to have a different icon in first place?
And the answer for that is you want to launch a real command, intercepted by your running application from the Jumpllist. exactly like Windows Media Player and other programs do.
In the next post I’ll show how to do that, so stay tuned.
Meanwhile you can download my code from here.