Click here to Skip to main content
15,891,864 members
Articles / Desktop Programming / WPF

WPF: Integrating our application with the Windows 7 Taskbar (I)

Rate me:
Please Sign up or sign in to vote.
4.50/5 (8 votes)
24 Jul 2010CPOL6 min read 43.4K   1.1K   24  
The taskbar of Windows 7 is one of the major changes in the Operating System, and brings many advantages.
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Taskbar IconOverlay &amp; ProgressBar" Height="350" Width="525">
    
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo/>
    </Window.TaskbarItemInfo>
    
    <Window.Resources>
        <DrawingImage x:Key="IconRed">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/FireToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
        <DrawingImage x:Key="IconGreen">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/GreenToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
        <DrawingImage x:Key="IconBlue">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/BlueToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
        <DrawingImage x:Key="IconPink">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/PinkToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
        <DrawingImage x:Key="IconBlack">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/NinjaToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
    </Window.Resources>
    
    <Grid>
        <Grid.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Offset="0" Color="Black"></GradientStop>
                <GradientStop Offset="1" Color="DarkGray"></GradientStop>
            </LinearGradientBrush>
        </Grid.Background>
        <TabControl Margin="12,6,12,12" Name="TabControl1">
            <TabItem Header="Taskbar IconOverlay" Name="TabItem1">
                <Grid>
                    <Grid.Background>
                        <ImageBrush ImageSource="pack://application:,,,/WPF Icon Overlay And ProgressBar;component/images/overlay.png" Stretch="Uniform" Opacity=".2" />
                    </Grid.Background>
                    <Grid.RowDefinitions>
                        <RowDefinition Height=".33*"></RowDefinition>
                        <RowDefinition Height=".33*"></RowDefinition>
                        <RowDefinition Height=".33*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    
                    <Label Grid.ColumnSpan="5" Grid.Row="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="24" Foreground="White"
                           Content="Select an image to overlay">
                    </Label>
                    
                    <Button Grid.Column="0" Grid.Row="1" Name="btnIconRed" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconRed}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>
                    <Button Grid.Column="1" Grid.Row="1" Name="btnIconGreen" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconGreen}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>
                    <Button Grid.Column="2" Grid.Row="1" Name="btnIconBlue" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconBlue}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>
                    <Button Grid.Column="3" Grid.Row="1" Name="btnIconPink" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconPink}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>
                    <Button Grid.Column="4" Grid.Row="1" Name="btnIconBlack" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconBlack}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>                    
                    
                    <Button Grid.ColumnSpan="5" Grid.Row="2" Name="btnIconReset" Width="125" Height="30">Reset Overlay</Button>
                </Grid>
            </TabItem>
            <TabItem Header="Taskbar ProgressBar" Name="TabItem2">
                <Grid>
                    <Grid.Background>
                        <ImageBrush ImageSource="pack://application:,,,/WPF Icon Overlay And ProgressBar;component/images/progressbar.png" Stretch="Uniform" Opacity=".2" />
                    </Grid.Background>
                    <Grid.RowDefinitions>
                        <RowDefinition Height=".25*"></RowDefinition>
                        <RowDefinition Height=".25*"></RowDefinition>
                        <RowDefinition Height=".25*"></RowDefinition>
                        <RowDefinition Height=".25*"></RowDefinition>
                    </Grid.RowDefinitions>

                    <Label Grid.Row="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="24" Foreground="White"
                           Content="Move the slider">
                    </Label>
                    
                    <ComboBox Grid.Row="1" Name="cmbEstilos" Height="30" Width="Auto" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <ComboBox.Items>
                            <ComboBoxItem Name="ItemNormal" Content="Normal"></ComboBoxItem>
                            <ComboBoxItem Name="ItemError" Content="Error"></ComboBoxItem>
                            <ComboBoxItem Name="ItemStop" Content="Stop"></ComboBoxItem>
                            <ComboBoxItem Name="ItemIndeterminate" Content="Indeterminate"></ComboBoxItem>
                            <ComboBoxItem Name="ItemNone" Content="None"></ComboBoxItem>
                        </ComboBox.Items>
                    </ComboBox>
                    
                    <ProgressBar Grid.Row="2" Name="Pbar" Height="30" Width="Auto" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                 Minimum="0" Maximum="100" Value="{Binding Path=Value, ElementName=SlidValue}"></ProgressBar>
                    
                    <Slider Grid.Row="3" Name="SlidValue" Height="30" Width="Auto" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                            Minimum="0" Maximum="100" Value="50" SmallChange="1">
                    </Slider>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Freelance Developer
Spain Spain
MVP Windows Platform Development 2014
MVP Windows Phone Development 2013
MVP Windows Phone Development 2012

Comments and Discussions