Zayko in the Net

Personal blog of Vitaly Zayko

NAVIGATION - SEARCH

Adding Buttons to Window Thumbnail in WPF 4 for Windows 7 (C#)

I'm pretty sure you all noticed that when you move your cursor under an App in Windows 7 Task bar, small window copy (aka Thumbnail) appear and there are small buttons on some windows could be attached. Good examples are Windows Media Player or WinAmp.

Windows Player Thumbnail with buttons on it

There is a good reason to put such buttons there: using them you can manage this Application without necessity to open its window.
Here is how to add this functionality to your own WPF App.
Add reference to TaskBatItemInfo just like we did to add progress bar in this post.
Add references to ThumbButtonInfo, so you will see something like this:

 <Window.TaskbarItemInfo>
     <TaskbarItemInfo>
         <TaskbarItemInfo.ThumbButtonInfos>
             <ThumbButtonInfo ImageSource="/IconProgressDemo;component/Icon1.ico" Description="Play!" Click="ThumbButtonInfo_Click" />
             <ThumbButtonInfo ImageSource="/IconProgressDemo;component/Icon2.ico" Description="Stop!" Click="ThumbButtonInfo_Click" />
         </TaskbarItemInfo.ThumbButtonInfos>
     </TaskbarItemInfo>
 </Window.TaskbarItemInfo>
 

Now just handle Click event in way you want and you done!

 private  void  ThumbButtonInfo_Click(object  sender, EventArgs  e)
 {
     MessageBox .Show((sender as  System.Windows.Shell.ThumbButtonInfo ).Description);
 }
 
Technorati Tags: ,,

Add comment