One of the exciting new features in .NET 4 is the ability to use Windows 7 Shell features like Jump Lists, Thumbnail Buttons, and progress indicators in Taskbar buttons, with your WPF applications. These features are found in the System.Windows.Shell namespace in .NET 4.
However, if you need to target .NET 3.5SP1, which ships with Windows 7, you can still use these features thanks to the WPF Shell Integration Library that is now available on MSDN Code Gallery.
The WPF Shell Integration Library shares the same features that are found in .NET 4, and the APIs are very compatible. This means it will be easy to upgrade your application to .NET 4 with only minor changes to the shell integration code. It also means that almost all of the documentation for the System.Windows.Shell namespace also applies to the WPF Shell Integration Library. There are a few differences, as noted on Code Gallery:
- TaskbarItemInfo is implemented as an attached property on the TaskbarItemInfo class, and is attached to an instance of a Window. In .NET 4, the TaskbarItemInfo is a property directly on Window.
- A TaskbarItemInfo instance has a strong affinity to a single window and cannot be shared.
- Features are in the Microsoft.Windows.Shell namespace, and in the http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell xmlns. In .NET 4, the taskbar integration APIs are within the System.Windows.Shell namespace and the standard WPF xmlns.
To see how similar the APIs are, and what the differences are, I took the sample code for the TaskbarItemInfo class from the MSDN documentation, and converted it to work with the WPF Shell Integration Library on .NET 3.5SP1. What changes were needed? Let’s see…
First, I downloaded the library from Code Gallery.
Then I added a reference to Microsoft.Windows.Shell.dll to my sample project, and in MainWindow.xaml, I added the required xmlns: xmlns:shell=http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell.
From there, I changed <Window.TaskbarItemInfo> to <shell:TaskbarItemInfo.TaskbarItemInfo>, and then added the shell: prefix to the rest of the tags.
Description="Taskbar Item Info Sample">
In the code behind page, I just changed my using/Imports statement from System.Windows.Shell to Microsoft.Windows.Shell.
That’s it. With these few changes, the TaskbarItemInfo sample runs on .NET 3.5 exactly as it does on .NET 4.