Windows 7 Taskbar Programming with WPF


Using the Taskbar ItemInfo in windows presentation foundation to add Thumb-Buttons,Overlay icons and Progress bar in the taskbar. Using WPF we can enhance the user experience of application running on windows 7. This code only works on Windows 7

Windows 7 Taskbar Programming with WPF



WPF has many features that enhance application user experience for applications running on Windows 7.
Some of the features are

1) Thumbnail buttons : These are small buttons that are visible just below the Application thumbnail when you take your cursor over a minimized application.
2) Overlay icons : These are icons which are visible on the Application Icon on the Taskbar.
3) Progress bar icons : This will be a progress bar which will be inside an Taskbar Icon.

We will first see how to work with the Thumbnail Buttons .

For thumbnail buttons to be displayed properly you need to have an Image.
In the example below I have added Three Thumbnail Buttons to an Application.
With the following code in the XAML

< Window.TaskbarItemInfo >
< TaskbarItemInfo >
< TaskbarItemInfo.ThumbButtonInfos >
< ThumbButtonInfo x:Name="btnBack" ImageSource="/Windows7Development;component/Images/Back.png" Description="Back Button" >
< /ThumbButtonInfo >
< ThumbButtonInfo x:Name="btnStop" ImageSource="/Windows7Development;component/Images/Close.png" Description="Stop Button" >
< /ThumbButtonInfo >
< ThumbButtonInfo x:Name="btnNext" ImageSource="/Windows7Development;component/Images/Forward.png" Description="Next Button" >
< /ThumbButtonInfo >
< /TaskbarItemInfo.ThumbButtonInfos >
< /TaskbarItemInfo >
< /Window.TaskbarItemInfo >

The Window.TaskbarItemInfo property allows you to interact with the Taskbar and then the TaskbarItemInfo.ThumbButtonInfos Section is used to Add ThumbButtons to your Taskbar using the ThumbButtonInfo.

The ImageSource property of the ThumbButtonInfo is used to assign the button a Image ,The Description property acts like a ToolTip.

You can use the Click events of these buttons to give actions on the clicks.


Now let us see how to work with the Overlay Icons.
To show the OverlayIcon you need to add the following code in the XAML inside the Window.TaskBarItemInfo section.
Type this

< TaskbarItemInfo.Overlay >
< DrawingImage >
< DrawingImage.Drawing >
< ImageDrawing Rect="0,0,32,32" ImageSource="/Windows7Development;component/Images/User.png" >< / ImageDrawing >
< /DrawingImage.Drawing >
< /DrawingImage >
< /TaskbarItemInfo.Overlay >

If you want to clear the Overlay icon you can use the following code

Me.TaskbarItemInfo.Overlay = Nothing

Now let us check the last section in this article about how to use the Progress Bar in the Taskbar.
You just need to add Two Attributes to the TaskbarItemInfo section

< TaskbarItemInfo ProgressState="Error" ProgressValue="0.5" >

The ProgressState and ProgressValue

You can use the following values in the ProgressState

Error : Will display a Red colored progressbar
Indeterminate : Will display a marquee type progressbar
Pause : Will display a yellow progressbar
None : Will display no progressbar
Normal : Will display the normal Green Progressbar.

You can also change the values and state of the progress bar at the runtime by using

Me.TaskbarItemInfo.ProgressState = Shell.TaskbarItemProgressState.Normal
Me.TaskbarItemInfo.ProgressValue = 0.9

If the ProgressValue is set to "1" it would be 100% progress so you need to use values like 0.1, 0.5 etc...

Hope to see you implement these features in your next WPF Applications.

For your reference I have attached the Example of this project in this article.


Attachments

  • Windows 7 Taskbar Programming Sample (43129-25748-Windows7Development.zip)
  • Comments

    No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: