Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Anatomy of the Windows 7 taskbar - Progress

0.00/5 (No votes)
26 Oct 2010 2  
Anatomy of the Windows 7 taskbar - Progress

Ever noticed the subtle progress overlay while downloading something from the internet? With Windows 7’s new taskbar, applications can visually display their progress on the taskbar!

We first need to set the mode:

TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal);

The Windows 7 taskbar has 5 possible states:

  • NoProgress - No progress is displayed
  • Indeterminate - The progress is indeterminate (marquee)
  • Normal - Normal progress is displayed
  • Error - An error occurred (red)
  • Paused - The operation is paused (yellow)

If the state is changed to Normal, then you can also set the value:

TaskbarManager.Instance.SetProgressValue(50, 100);

Easy? Isn't it?

What would a post be without trying to make it just a little easier for the WPF developers? I also created an attached property that auto-magically links a WPF ProgressBar to the Windows 7 taskbar…

Here is my very simple demo:

<Window x:Class="ProgressDemo.Window1"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:="clr-namespace:ProgressDemo"

    Title="ProgressDemo" Height="100" Width="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Slider Minimum="0" Maximum="100" x:Name="source" Grid.Row="0" />
        <ProgressBar Minimum="0" Maximum="100" Grid.Row="1" Height="20"

             Value="{Binding ElementName=source, Path=Value}" 

             local:Win7.ShowProgressInTaskbar="True" />
    </Grid>
</Window>

As you can see from this XAML, I created a Slider and bound it to the ProgressBar. To make the ProgressBar auto-magically update the Windows 7 taskbar, all we need to do is set the ShowProgressInTaskbar=”True”!!!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here