Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

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

, 24 Jul 2010
The taskbar of Windows 7 is one of the major changes in the Operating System, and brings many advantages.
WPF_Icon_Overlay_And_ProgressBar.zip
WPF Icon Overlay And ProgressBar
bin
Debug
WPF Icon Overlay And ProgressBar.vshost.exe
WPF Icon Overlay And ProgressBar.vshost.exe.manifest
images
BlueToy.ico
FireToy.ico
GreenToy.ico
NinjaToy.ico
overlay.png
PinkToy.ico
progressbar.png
My Project
MyExtensions
Settings.settings
WPF Icon Overlay And ProgressBar.vbproj.user
<Application x:Class="Application"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wintheme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    StartupUri="MainWindow.xaml">
    <Application.Resources>
        <SolidColorBrush x:Key="BaseColor" Color="#BB000000"></SolidColorBrush>
        <LinearGradientBrush x:Key="ProgressBrush" StartPoint="0,0" EndPoint="1,0">
            <GradientStop Offset="0" Color="DarkGreen"></GradientStop>
            <GradientStop Offset=".95" Color="LightGreen"></GradientStop>
            <GradientStop Offset="1" Color="#0077FF77"></GradientStop>
        </LinearGradientBrush>
        <!-- GLASS EFFECT -->
        <LinearGradientBrush x:Key="GlassFX" StartPoint=".5,0" EndPoint=".5,.5">
            <GradientStop Offset="1" Color="#33DDDDDD"></GradientStop>
            <GradientStop Offset="1" Color="#33000000"></GradientStop>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GlassFXDisabled" StartPoint=".5,0" EndPoint=".5,.5">
            <GradientStop Offset="1" Color="#33BBBBBB"></GradientStop>
            <GradientStop Offset="1" Color="#11000000"></GradientStop>
        </LinearGradientBrush>

        <!-- GLOW EFFECT -->
        <RadialGradientBrush x:Key="GlowFX" GradientOrigin=".5,1" Center=".5,1">
            <GradientStop Offset="0" Color="#990000FF"></GradientStop>
            <GradientStop Offset=".5" Color="#660000DD"></GradientStop>
            <GradientStop Offset="1" Color="#33000000"></GradientStop>
        </RadialGradientBrush>
        <RadialGradientBrush x:Key="GlowFXPressed" GradientOrigin=".5,1" Center=".5,1">
            <GradientStop Offset="0" Color="#660000CC"></GradientStop>
            <GradientStop Offset="1.2" Color="#33FFFFFF"></GradientStop>
        </RadialGradientBrush>
        <LinearGradientBrush x:Key="GlowFXRowPressed">
            <GradientStop Offset="0" Color="#660000FF"></GradientStop>
            <GradientStop Offset=".7" Color="#660000AA"></GradientStop>
            <GradientStop Offset="1" Color="#66000000"></GradientStop>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GlowFXProgress">
            <GradientStop Offset="0" Color="#660099FF"></GradientStop>
            <GradientStop Offset=".99" Color="#660022AA"></GradientStop>
            <GradientStop Offset="1" Color="#00000000"></GradientStop>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GlowFXProgressAnimated" MappingMode="RelativeToBoundingBox">
            <GradientStop Offset="0" Color="#00000000"></GradientStop>
            <GradientStop Offset=".50" Color="#660099FF"></GradientStop>
            <GradientStop Offset="1" Color="#00000000"></GradientStop>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GlowFXTabSelected" StartPoint=".5,1" EndPoint=".5,0">
            <GradientStop Offset="0" Color="#33DDDDDD"></GradientStop>
            <GradientStop Offset="1" Color="#332222FF"></GradientStop>
        </LinearGradientBrush>

        <!-- CHECKED COLORS -->
        <LinearGradientBrush x:Key="CheckedGreen">
            <GradientStop Offset="0" Color="#6600FF99"></GradientStop>
            <GradientStop Offset=".99" Color="#6600AA22"></GradientStop>
            <GradientStop Offset="1" Color="#00000000"></GradientStop>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="UncheckedRed">
            <GradientStop Offset="0" Color="#66FF2200"></GradientStop>
            <GradientStop Offset=".99" Color="#66BB2200"></GradientStop>
            <GradientStop Offset="1" Color="#00000000"></GradientStop>
        </LinearGradientBrush>

        <!-- GLOW ANIMATION -->
        <Storyboard x:Key="GlowOut">
            <DoubleAnimation x:Name="AnimGlowOut" BeginTime="00:00:00" Storyboard.TargetName="GlowRectangle" Duration="00:00:00.250" From="1" To="0" Storyboard.TargetProperty="Opacity"></DoubleAnimation>
        </Storyboard>
        <Storyboard x:Key="GlowIn">
            <DoubleAnimation x:Name="AnimGlow" BeginTime="00:00:00" Storyboard.TargetName="GlowRectangle" Duration="00:00:00.250" From="0" To="1" Storyboard.TargetProperty="Opacity">
            </DoubleAnimation>
        </Storyboard>


        <!-- PROGRESSBAR Imitando una pila. -->
        <Style TargetType="{x:Type ProgressBar}">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ProgressBar}">
                        <Grid MinHeight="14" MinWidth="20">
                            <Border x:Name="BaseRectangle" Background="{StaticResource BaseColor}" CornerRadius="10,0,10,0"></Border>
                            <Border x:Name="animation" CornerRadius="10,0,10,0" Opacity=".7" Background="{StaticResource ProgressBrush}" HorizontalAlignment="Left"></Border>
                            <Border x:Name="PART_Indicator" CornerRadius="10,0,10,0" Background="{StaticResource ProgressBrush}" HorizontalAlignment="Left"></Border>
                            <Border x:Name="GlassRectangle" CornerRadius="10,0,10,0"  Background="{StaticResource GlassFX}"></Border>
                            <Border x:Name="PART_Track" BorderThickness="1" CornerRadius="10,0,10,0" BorderBrush="Black"></Border>
                            <Border x:Name="BordeCabeceraSombra" BorderThickness="2" CornerRadius="10,0,10,0" BorderBrush="DarkGray" Opacity=".2" Margin="1,1,1,0"></Border>
                            <Label x:Name="Progress" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontWeight="Bold" Foreground="White" Opacity=".7" Content="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}}"></Label>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsIndeterminate" Value="True">
                                <Setter Property="Visibility" TargetName="Progress" Value="Hidden"></Setter>
                                <Setter Property="Background" TargetName="PART_Indicator">
                                    <Setter.Value>
                                        <MultiBinding>
                                            <MultiBinding.Converter>
                                                <wintheme:ProgressBarHighlightConverter/>
                                            </MultiBinding.Converter>
                                            <Binding Source="{StaticResource GlowFXProgressAnimated}"/>
                                            <Binding Path="ActualWidth"  ElementName="BaseRectangle"/>
                                            <Binding Path="ActualHeight" ElementName="BaseRectangle"/>
                                        </MultiBinding>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" Value=".5"></Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- TABCONTROL -->
        <Style TargetType="{x:Type TabItem}">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid Name="grdTab" Margin="1,0,0,0" Height="20">
                            <Border Name="BaseBorder" Margin="0,0,-4,0" Background="{StaticResource BaseColor}" CornerRadius="2,12,0,0" Height="20"></Border>
                            <Border Name="Border" Margin="0,0,-4,0" Background="{StaticResource GlassFX}" BorderBrush="Black"  BorderThickness="1,1,1,1" CornerRadius="2,12,0,0" Height="20" >
                                <Grid  Margin="12,2,12,2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"></ColumnDefinition>
                                        <ColumnDefinition Width="10"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <ContentPresenter x:Name="ContentSite" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Header" RecognizesAccessKey="True" Height="20"/>
                                </Grid>
                            </Border>
                            <Border x:Name="GlowRectangle" Margin="0,0,-4,0" CornerRadius="2,12,0,0" Opacity="0" Background="{StaticResource GlowFX}" Height="20"></Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" Value=".5" />
                            </Trigger>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" TargetName="Border" Value="{StaticResource GlowFXTabSelected}" />
                            </Trigger>
                            <EventTrigger RoutedEvent="MouseLeave">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Storyboard="{StaticResource GlowOut}"></BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                            <EventTrigger RoutedEvent="MouseEnter">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Storyboard="{StaticResource GlowIn}"></BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style  TargetType="{x:Type TabControl}">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabControl}">
                        <Grid KeyboardNavigation.TabNavigation="Local" Margin="0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="3"></ColumnDefinition>
                                <ColumnDefinition Width="*"></ColumnDefinition>
                                <ColumnDefinition Width="3"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TabPanel Name="HeaderPanel" Grid.Row="0" Panel.ZIndex="1" Grid.Column="1"  Margin="0,0,4,-1" IsItemsHost="True" KeyboardNavigation.TabIndex="1" Background="Transparent" />
                            <Grid Grid.Row="1" Grid.ColumnSpan="3" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <Border Name="BaseBorder" Background="{StaticResource BaseColor}"  BorderBrush="Black" BorderThickness="1" CornerRadius="5"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0">
                                    <Border Name="Border" Background="{StaticResource GlassFX}"  BorderBrush="Black" BorderThickness="1" CornerRadius="5"
                                            KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" Opacity="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0">
                                        <ContentPresenter Name="PART_SelectedContentHost" Margin="0" ContentSource="SelectedContent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Grid, AncestorLevel=1}, Path=ActualWidth}" Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Grid, AncestorLevel=1}, Path=ActualHeight}">
                                        </ContentPresenter>
                                    </Border>
                                </Border>
                            </Grid>

                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" Value=".5" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- CHECKBOX -->
        <ControlTemplate x:Key="RadCheckTemplate">
            <Grid x:Name="MainGrid">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                    <ColumnDefinition Width="60"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="Contenido" Grid.Column="0" VerticalAlignment="Center" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"></ContentPresenter>
                <Border x:Name="border" CornerRadius="1,1,1,1" BorderThickness="1,1,1,1" Grid.Column="1" BorderBrush="Black" Background="{StaticResource BaseColor}">
                    <Grid x:Name="grid" Height="Auto" Width="Auto" Background="#FF000000" VerticalAlignment="Stretch">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" x:Name="columnDefinition"/>
                            <ColumnDefinition Width="Auto" x:Name="columnDefinition2"/>
                            <ColumnDefinition Width="Auto" x:Name="columnDefinition1"/>
                        </Grid.ColumnDefinitions>
                        <Rectangle Stroke="#FFA1A1A1" Fill="{StaticResource GlassFX}" Margin="0,0,0,0" Grid.Column="1" Grid.ColumnSpan="1" Width="30" x:Name="rectangle" StrokeThickness="1" RadiusY="1" RadiusX="1" VerticalAlignment="Stretch" Height="Auto">
                        </Rectangle>
                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="SI" TextWrapping="Wrap" Grid.Column="0" Width="30" Height="Auto" TextAlignment="Center" Visibility="Collapsed" x:Name="ON" FontFamily="Calibri" FontSize="14" FontWeight="Bold" Foreground="#FFFFFFFF">
								<TextBlock.Background>
									<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
										<GradientStop Color="#FF7DA9DE" Offset="0"/>
										<GradientStop Color="#FF417AF5" Offset="0.996"/>
									</LinearGradientBrush>
								</TextBlock.Background>
                        </TextBlock>
                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Height="Auto" Text="NO" TextWrapping="Wrap" Margin="0,0,0,0" Grid.Column="2" Width="30" TextAlignment="Center" x:Name="OFF" Foreground="#FFFFFFFF" FontWeight="Bold" FontFamily="Calibri" FontSize="14" Background="{StaticResource UncheckedRed}"/>
                    </Grid>
                </Border>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="CheckBox.IsChecked" Value="True">
                    <Setter Property="Visibility" TargetName="ON" Value="Visible"/>
                    <Setter Property="Visibility" TargetName="OFF" Value="Collapsed"/>
                    <Setter Property="Background" TargetName="ON" Value="{StaticResource CheckedGreen}">
                    </Setter>
                </Trigger>
                <Trigger Property="CheckBox.IsPressed" Value="True"/>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Opacity" Value=".5"/>
                    <Setter Property="CheckBox.IsChecked" Value="False"></Setter>
                    <Setter Property="Background" TargetName="OFF" Value="Transparent"></Setter>
                    <Setter Property="Text" TargetName="OFF" Value=""></Setter>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <Style TargetType="{x:Type CheckBox}">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="Template" Value="{StaticResource RadCheckTemplate}"></Setter>
        </Style>

        <!-- BOTON -->
        <Style TargetType="{x:Type Button}">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate x:Name="tmpltButton">
                        <Grid>
                            <Border x:Name="BaseRectangle" 
                                    Background="{StaticResource BaseColor}" 
                                    CornerRadius="10,0,10,0">
                            </Border>
                            <Border x:Name="GlassRectangle" 
                                    Background="{StaticResource GlassFX}" 
                                    CornerRadius="10,0,10,0">
                            </Border>
                            <Border x:Name="GlowRectangle" 
                                    Background="{StaticResource GlowFX}" 
                                    CornerRadius="10,0,10,0" 
                                    Opacity="0">
                            </Border>
                            <Border x:Name="ButtonBorder" 
                                    CornerRadius="10,0,10,0" 
                                    BorderBrush="Black" 
                                    Opacity="1"  
                                    BorderThickness="1">
                            </Border>
                            <ContentPresenter x:Name="ButtonContent" 
                                              Opacity=".7" 
                                              Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" 
                                              HorizontalAlignment="center" 
                                              VerticalAlignment="center">
                            </ContentPresenter>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <EventTrigger RoutedEvent="Button.MouseLeave">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Storyboard="{StaticResource GlowOut}"></BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                            <EventTrigger RoutedEvent="Button.MouseEnter">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Storyboard="{StaticResource GlowIn}"></BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                            <EventTrigger RoutedEvent="Button.LostFocus">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Storyboard="{StaticResource GlowOut}"></BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                            <EventTrigger RoutedEvent="Button.GotFocus">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Storyboard="{StaticResource GlowIn}"></BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                            <Trigger Property="Button.IsPressed" Value="True">
                                <Setter Property="Background" TargetName="GlowRectangle" Value="{StaticResource GlowFXPressed}"></Setter>
                                <Setter Property="Opacity" TargetName="ButtonContent" Value="1"></Setter>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" TargetName="ButtonContent" Value=".3"></Setter>
                                <Setter Property="Opacity" TargetName="ButtonBorder" Value=".5"></Setter>
                                <Setter Property="Background" TargetName="GlassRectangle" Value="{StaticResource GlassFXDisabled}"></Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- COMBOBOX -->
        <ControlTemplate x:Key="cmbToggleButton" TargetType="ToggleButton">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition Width="20"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Rectangle x:Name="BaseRectangle" Fill="{StaticResource BaseColor}" RadiusX="3" RadiusY="3" Grid.ColumnSpan="2"></Rectangle>
                <Rectangle x:Name="GlowRectangle" RadiusX="5" RadiusY="5" Opacity="0" Fill="{StaticResource GlowFX}" Grid.Column="0"></Rectangle>
                <Border  x:Name="Border" Grid.ColumnSpan="2" Background="{StaticResource GlassFX}" BorderBrush="Black" BorderThickness="1" CornerRadius="3" />
                <Border Grid.Column="0" CornerRadius="3,0,0,3" Margin="1" Background="{StaticResource GlassFX}" BorderBrush="DarkBlue"  BorderThickness="0,0,1,0" />
                <Path x:Name="Arrow" Grid.Column="1" Fill="Cyan" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 4 4 L 8 0 Z"/>
            </Grid>
            <ControlTemplate.Triggers>
                <EventTrigger RoutedEvent="ToggleButton.MouseLeave">
                    <EventTrigger.Actions>
                        <BeginStoryboard Storyboard="{StaticResource GlowOut}"></BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
                <EventTrigger RoutedEvent="ToggleButton.MouseEnter">
                    <EventTrigger.Actions>
                        <BeginStoryboard Storyboard="{StaticResource GlowIn}"></BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
                <Trigger Property="ToggleButton.IsChecked" Value="true">
                    <Setter TargetName="Border" Property="Background" Value="{StaticResource GlowFXPressed}" />
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Opacity" TargetName="Border" Value=".3"></Setter>
                    <Setter Property="Opacity" TargetName="Arrow" Value=".5"></Setter>
                    <Setter Property="Background" TargetName="Border" Value="{StaticResource GlassFXDisabled}"></Setter>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <ControlTemplate x:Key="ComboBoxTextBox" TargetType="TextBox">
            <Border x:Name="PART_ContentHost" Focusable="False" Background="Transparent" />
        </ControlTemplate>
        <Style TargetType="{x:Type ComboBox}">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.CanContentScroll" Value="true"></Setter>
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate x:Name="tmplTextBox" TargetType="ComboBox">
                        <Grid>
                            <ToggleButton Name="ToggleButton" Template="{StaticResource cmbToggleButton}" Grid.Column="2" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press">
                            </ToggleButton>
                            <ContentPresenter
            Name="ContentSite"
            IsHitTestVisible="False" 
            Content="{TemplateBinding SelectionBoxItem}"
            ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
            ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
            Margin="3,3,23,3"
            VerticalAlignment="Center"
            HorizontalAlignment="Left" />

                            <TextBox x:Name="PART_EditableTextBox" HorizontalAlignment="Stretch" Foreground="White" VerticalAlignment="Stretch" Margin="1,1,23,1" Focusable="True" Visibility="Hidden" IsReadOnly="{TemplateBinding ComboBox.IsReadOnly}"/>
                            <Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding ComboBox.IsDropDownOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Slide">
                                <Grid Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}">
                                    <Rectangle x:Name="BaseRectangle" Fill="#99000000" RadiusX="3" RadiusY="3" Grid.ColumnSpan="2"></Rectangle>
                                    <Border x:Name="DropDownBorder" Background="{StaticResource GlassFX}" BorderThickness="1" BorderBrush="DarkBlue" CornerRadius="3"/>
                                    <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
                                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
                                    </ScrollViewer>
                                </Grid>
                            </Popup>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="HasItems" Value="false">
                                <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{StaticResource GlassFXDisabled}"/>
                            </Trigger>
                            <Trigger Property="IsGrouping" Value="true">
                                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                            </Trigger>
                            <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
                                <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4"/>
                                <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0"/>
                            </Trigger>
                            <Trigger Property="IsEditable" Value="true">
                                <Setter Property="IsTabStop" Value="false"/>
                                <Setter TargetName="PART_EditableTextBox" Property="Visibility"    Value="Visible"/>
                                <Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- TEXTBOX -->
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate x:Name="tmpltTextBox">
                        <Grid>
                            <Rectangle x:Name="BaseRectangle" Fill="{StaticResource BaseColor}" RadiusX="3" RadiusY="3"></Rectangle>
                            <Rectangle x:Name="GlassRectangle" RadiusX="5" RadiusY="5" Fill="{StaticResource GlassFX}"></Rectangle>
                            <Rectangle x:Name="GlowRectangle" RadiusX="5" RadiusY="5" Opacity="0" Fill="{StaticResource GlowFX}"></Rectangle>
                            <Border x:Name="BorderIntern" Opacity="1" BorderBrush="Black" BorderThickness="2" CornerRadius="3" Margin="1,1,-1,-1"></Border>
                            <Border x:Name="BorderExtern" Opacity="1" BorderBrush="#FF333333" BorderThickness="1" CornerRadius="3"></Border>
                            <ScrollViewer x:Name="PART_ContentHost" Opacity=".7" Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="{Binding Path=HorizontalAlignment, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{Binding Path=VerticalAlignment, RelativeSource={RelativeSource TemplatedParent}}" Width="{Binding Path=Width, RelativeSource={RelativeSource TemplatedParent}}" Height="{Binding Path=Height, RelativeSource={RelativeSource TemplatedParent}}"></ScrollViewer>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <EventTrigger RoutedEvent="TextBox.LostFocus">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Storyboard="{StaticResource GlowOut}"></BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                            <EventTrigger RoutedEvent="TextBox.GotFocus">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Storyboard="{StaticResource GlowIn}"></BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" TargetName="PART_ContentHost" Value=".3"></Setter>
                                <Setter Property="Opacity" TargetName="BorderExtern" Value=".5"></Setter>
                                <Setter Property="Fill" TargetName="GlassRectangle" Value="{StaticResource GlassFXDisabled}"></Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>
</Application>

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)

Share

About the Author

JOSUEYERAY
Software Developer Plain Concepts
Spain Spain
MCP - .NET Framework 2.0 Application Development Fundamentals
MCTS - .NET Framework 3.5 Windows Forms Application
MCTS - .NET Framework 3.5 Windows Presentation Foundation

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 24 Jul 2010
Article Copyright 2010 by JOSUEYERAY
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid