WPF Shell Integration Library for .NET 3.5

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:

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=https://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.

    <shell:TaskbarItemInfo.TaskbarItemInfo>

        <shell:TaskbarItemInfo x:Name="taskBarItemInfo1"

                    Overlay="{StaticResource ResourceKey=StopImage}"

                    ThumbnailClipMargin="80,0,80,140"

                    Description="Taskbar Item Info Sample">

            <shell:TaskbarItemInfo.ThumbButtonInfos>

                <shell:ThumbButtonInfoCollection>

                    <shell:ThumbButtonInfo

                   DismissWhenClicked="False"

                   Command="MediaCommands.Play"

                   CommandTarget="{Binding ElementName=btnPlay}"

                   Description="Play"

                   ImageSource="{StaticResource ResourceKey=PlayImage}"/>

                  <shell:ThumbButtonInfo

                   DismissWhenClicked="True"

                   Command="MediaCommands.Stop"

                   CommandTarget="{Binding ElementName=btnStop}"

                   Description="Stop"

                   ImageSource="{StaticResource ResourceKey=StopImage}"/>

                </shell:ThumbButtonInfoCollection>

            </shell:TaskbarItemInfo.ThumbButtonInfos>

        </shell:TaskbarItemInfo>

    </shell:TaskbarItemInfo.TaskbarItemInfo>

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.