Click here to Skip to main content
15,883,901 members
Articles / Desktop Programming / WPF

Sonic: A WPF (hybrid smart client) searchable media library

Rate me:
Please Sign up or sign in to vote.
4.87/5 (228 votes)
21 Feb 2009CPOL20 min read 366K   4.6K   309  
A queryable working MP3 player, using some cool LINQ stuff.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:Sonic"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna">









    <!-- Brushes-->
    <LinearGradientBrush x:Key="orangeHighlightBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFBD69" Offset="0"/>
        <GradientStop Color="#FFFB8C3C" Offset="0.165"/>
        <GradientStop Color="#FFFEB461" Offset="0.9677"/>
        <GradientStop Color="#FFFEBB67" Offset="1"/>
        <GradientStop Color="#FFFB8C3C" Offset="0.786"/>
    </LinearGradientBrush>



    <!-- ScrollBarPageButton -->
    <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="{DynamicResource transparentBackGround}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- VerticalScrolScrollBarThumblBar -->
    <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border 
          CornerRadius="4" 
          Background="{TemplateBinding Background}"
          BorderBrush="{TemplateBinding BorderBrush}"
          BorderThickness="1" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- VerticalScrollBar -->
    <ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid Background="{DynamicResource transparentBackGround}" >
            <Grid.RowDefinitions>
                <RowDefinition Height="0.00001*"/>
            </Grid.RowDefinitions>
            <Border
      Grid.RowSpan="1"
      CornerRadius="2" 
      Background="{DynamicResource transparentBackGround}" />
            <Track
      Name="PART_Track"
      Grid.Row="1"
      IsDirectionReversed="true">
                <Track.DecreaseRepeatButton>
                    <RepeatButton 
          Style="{StaticResource ScrollBarPageButton}"
          Command="ScrollBar.PageUpCommand" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Name="thumb"
          Style="{StaticResource ScrollBarThumb}" 
          Margin="3,0,3,0"  
          Background="Orange"
          BorderBrush="Black" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton 
          Style="{StaticResource ScrollBarPageButton}"
          Command="ScrollBar.PageDownCommand" />
                </Track.IncreaseRepeatButton>

            </Track>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.TargetName="thumb" 
                                    Storyboard.TargetProperty=
                                            "(Control.Background).(SolidColorBrush.Color)"                                       
                                    To="Red"
                                    Duration="0:0:0.5"  AccelerationRatio=".9"   />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.TargetName="thumb" 
                                    Storyboard.TargetProperty=
                                            "(Control.Background).(SolidColorBrush.Color)"                                       
                                    To="Orange"
                                    Duration="0:0:0.5"  AccelerationRatio=".9"   />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- HorizontalScrollBar -->
    <ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid Background="{DynamicResource transparentBackGround}" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.00001*"/>
            </Grid.ColumnDefinitions>
            <Border
      Grid.ColumnSpan="1"
      CornerRadius="2" 
      Background="{DynamicResource transparentBackGround}" />
            <Track 
      Name="PART_Track"
      Grid.Column="1"
      IsDirectionReversed="False">
                <Track.DecreaseRepeatButton>
                    <RepeatButton 
          Style="{StaticResource ScrollBarPageButton}"
          Command="ScrollBar.PageLeftCommand" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Name="thumb"
          Style="{StaticResource ScrollBarThumb}" 
          Margin="0,3,0,3"  
          Background="Orange"
          BorderBrush="Black" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton 
          Style="{StaticResource ScrollBarPageButton}"
          Command="ScrollBar.PageRightCommand" />
                </Track.IncreaseRepeatButton>
            </Track>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.TargetName="thumb" 
                                    Storyboard.TargetProperty=
                                            "(Control.Background).(SolidColorBrush.Color)"                                       
                                    To="Red"
                                    Duration="0:0:0.5"  AccelerationRatio=".9"   />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.TargetName="thumb" 
                                    Storyboard.TargetProperty=
                                            "(Control.Background).(SolidColorBrush.Color)"                                       
                                    To="Orange"
                                    Duration="0:0:0.5"  AccelerationRatio=".9"   />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- ScrollBar -->
    <Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="Height" Value="14" />
                <Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Width" Value="14"/>
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- ScrollViewerStyle -->
    <Style TargetType="{x:Type ScrollViewer}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="HorizontalScrollBarVisibility" Value="Visible" />
        <Setter Property="VerticalScrollBarVisibility" Value="Visible" />
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="ContextMenu" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <ScrollContentPresenter Grid.Column="0"/>

                        <ScrollBar Name="PART_VerticalScrollBar"
                            Grid.Column="1"
                            Value="{TemplateBinding VerticalOffset}"
                            Maximum="{TemplateBinding ScrollableHeight}"
                            ViewportSize="{TemplateBinding ViewportHeight}"
                            Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                        <ScrollBar Name="PART_HorizontalScrollBar"
                            Orientation="Horizontal"
                            Grid.Row="1"
                            Grid.Column="0"
                            Value="{TemplateBinding HorizontalOffset}"
                            Maximum="{TemplateBinding ScrollableWidth}"
                            ViewportSize="{TemplateBinding ViewportWidth}"
                            Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <!-- Main Window Buttons -->
    <ControlTemplate x:Key="mainWinButtons" TargetType="{x:Type Button}">
        <Border x:Name="border" CornerRadius="3" 
                Background="Black" 
                BorderBrush="Black" 
                BorderThickness="1" 
                Width="30" Height="30" Visibility="Visible">

            <Label x:Name="lbl" Content="{TemplateBinding Content}" Foreground="Orange" 
                   HorizontalAlignment="Center" VerticalAlignment="Center"/>

        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter TargetName="border" Property="Background" Value="Orange"/>
                <Setter TargetName="border" Property="BorderBrush" Value="Orange"/>
                <Setter TargetName="lbl" Property="Foreground" Value="Black"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- Application ToolTip Styles -->
    <Style TargetType="ToolTip">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="HasDropShadow" Value="True"/>
        <Setter Property="Opacity" Value="0.8"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToolTip">
                    <Border Name="Border"
                          CornerRadius="2"
                          BorderBrush="Orange"
                          Background="Black"
                          BorderThickness="2"
                          Width="{TemplateBinding Width}"
                          Height="{TemplateBinding Height}">

                        <Label Foreground="Orange" FontFamily="Tahoma"
                            FontWeight="Bold" FontSize="10"
                            Margin="2" Content="{TemplateBinding Content}"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasDropShadow" Value="true">
                            <Setter TargetName="Border" 
                                    Property="CornerRadius" 
                                    Value="4"/>
                            <Setter TargetName="Border" 
                                    Property="SnapsToDevicePixels" 
                                    Value="true"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <Style x:Key="ResizeGripStyle1" TargetType="{x:Type ResizeGrip}">
        <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
        <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ResizeGrip}">
                    <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                        <Path HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Data="M 9,0 L 11,0 L 11,11 L 0,11 L 0,9 L 3,9 L 3,6 L 6,6 L 6,3 L 9,3 z">
                            <Path.Fill>
                                <DrawingBrush TileMode="Tile" Viewbox="0,0,3,3" ViewboxUnits="Absolute" Viewport="0,0,3,3" ViewportUnits="Absolute">
                                    <DrawingBrush.Drawing>
                                        <DrawingGroup>
                                            <GeometryDrawing Brush="Black" Geometry="M 0,0 L 2,0 L 2,2 L 0,2 z "/>
                                        </DrawingGroup>
                                    </DrawingBrush.Drawing>
                                </DrawingBrush>
                            </Path.Fill>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>




    <!-- Custom Window : to allow repositioning of ResizeGrip-->
    <ControlTemplate x:Key="WindowTemplateKey" TargetType="{x:Type Window}">
        <Border Background="{TemplateBinding Background}" 
                BorderBrush="{TemplateBinding BorderBrush}" 
                BorderThickness="{TemplateBinding BorderThickness}">
            <Grid>
                <AdornerDecorator>
                    <ContentPresenter/>
                </AdornerDecorator>
                <ResizeGrip Visibility="Collapsed" 
                            HorizontalAlignment="Right" x:Name="WindowResizeGrip" 
                            Style="{DynamicResource ResizeGripStyle1}" 
                            VerticalAlignment="Bottom" IsTabStop="false"/>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
                    <Condition Property="WindowState" Value="Normal"/>
                </MultiTrigger.Conditions>
                <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>




    <!-- Main Window Buttons -->
    <ControlTemplate x:Key="musicImage" TargetType="{x:Type Image}">
        <Image x:Name="img" Height="100"
                Stretch="Fill" Source="{TemplateBinding Source}">
        </Image>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter TargetName="img" Property="Effect" >
                    <Setter.Value>
                        <DropShadowEffect Color="Azure" Direction="315" ShadowDepth="5" Opacity="0.8"/>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>


    <Style x:Key="CommonFocusVisualStyle">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="-2" StrokeThickness="2" 
                               Stroke="White" StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <!-- TextBox Styles-->
    <Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="MinWidth" Value="120"/>
        <Setter Property="MinHeight" Value="20"/>
        <Setter Property="AllowDrop" Value="true"/>
        <Setter Property="TextElement.Foreground" Value="White"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="MaxLength" Value="40"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBoxBase}">
                    <Border 
                      Name="Border"
                      CornerRadius="5" 
                      Padding="1"
                      Background="Black"
                      BorderBrush="Orange"
                      BorderThickness="2" >
                        <Grid>
                            <Rectangle x:Name="dashes" Margin="1" StrokeThickness="1"
                                       HorizontalAlignment="Stretch" 
                                       VerticalAlignment="Stretch"
                               Stroke="Transparent" StrokeDashArray="0.5 4"/>

                            <ScrollViewer Margin="0" x:Name="PART_ContentHost"
                                          HorizontalAlignment="Stretch" 
                                          VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Border" Property="BitmapEffect" >
                                <Setter.Value>
                                    <OuterGlowBitmapEffect  GlowColor="Orange" 
                                        GlowSize="15" Opacity="0.7"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="dashes" Property="Stroke" 
                                    Value="Orange"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- ComboBox -->
    <Style x:Key="ComboBoxExTransparentButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="MinWidth" Value="0"/>
        <Setter Property="MinHeight" Value="0"/>
        <Setter Property="Width" Value="Auto"/>
        <Setter Property="Height" Value="Auto"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="ClickMode" Value="Press"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition SharedSizeGroup="ComboBoxButton" Width="Auto" 
                                              MinWidth="20"/>
                        </Grid.ColumnDefinitions>
                        <Label Grid.Column="1" Content="q"  FontFamily="Wingdings 3" 
                               Foreground="Black" FontSize="8" 
                               VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,0,0,-9"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <Style x:Key="RegularComboBox" TargetType="ComboBoxItem">
        <Setter Property="HorizontalContentAlignment" 
                Value="{Binding Path=HorizontalContentAlignment, 
                    RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" 
                Value="{Binding Path=VerticalContentAlignment, 
                    RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <Border 
                          Name="Border"
                          Padding="0"
                          SnapsToDevicePixels="true">
                        <ContentPresenter x:Name="cont" Margin="2,0,0,0" 
                                Height="25" HorizontalAlignment="Left" 
                                VerticalAlignment="Center" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="true">
                            <Setter TargetName="cont" Property="TextElement.Foreground" 
                                    Value="Red"/>
                            <Setter TargetName="cont" Property="TextElement.FontWeight" 
                                    Value="Bold"/>
                            <Setter TargetName="cont" Property="BitmapEffect" >
                                <Setter.Value>
                                    <OuterGlowBitmapEffect GlowColor="White" GlowSize="5" Opacity="0.6"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="BigComboBox" TargetType="ComboBoxItem">
        <Setter Property="HorizontalContentAlignment" 
                Value="{Binding Path=HorizontalContentAlignment, 
                    RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" 
                Value="{Binding Path=VerticalContentAlignment, 
                    RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="SnapsToDevicePixels" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                    <Border 
                          Name="Border"
                          Padding="2"
                          SnapsToDevicePixels="true">
                        <ContentPresenter x:Name="cont" Margin="2,0,0,0"   
                            HorizontalAlignment="Left" 
                            VerticalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHighlighted" Value="true">
                            <Setter TargetName="cont" Property="TextElement.Foreground" 
                                    Value="Red"/>
                            <Setter TargetName="cont" Property="TextElement.FontWeight" 
                                    Value="Bold"/>
                            <Setter TargetName="cont" Property="BitmapEffect" >
                                <Setter.Value>
                                    <OuterGlowBitmapEffect GlowColor="White" GlowSize="5" Opacity="0.6"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>





    <Style x:Key="{x:Type ComboBox}" TargetType="{x:Type ComboBox}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource CommonFocusVisualStyle}"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="ItemContainerStyle" Value="{StaticResource RegularComboBox}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBox}">
                    <Grid SnapsToDevicePixels="true">
                        <Border x:Name="Bd"
                                SnapsToDevicePixels="true" 
                                Height="{TemplateBinding Height}" 
                                Width="{TemplateBinding Width}"
                                VerticalAlignment="Center"
				                Background="Orange" 
				                CornerRadius="2"
				                BorderBrush="Orange" 
				                BorderThickness="1">
                            <Grid Grid.IsSharedSizeScope="true" Background="Orange">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Label x:Name="item" Background="Orange" 
                                       SnapsToDevicePixels="True" 
                                       HorizontalAlignment="Left" 
                                       FontWeight="{TemplateBinding FontWeight}"
                                       FontSize="{TemplateBinding FontSize}"
                                       Margin="0" VerticalAlignment="Center" 
                                       Grid.Column="0" Content="{TemplateBinding SelectionBoxItem}" 
                                       ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" 
                                       ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"/>
                                <ToggleButton Style="{StaticResource ComboBoxExTransparentButtonStyle}" 
                                        Grid.Column="0" Grid.ColumnSpan="2"
                                       IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, 
                                            RelativeSource={RelativeSource TemplatedParent}}"/>
                            </Grid>
                        </Border>
                        <Popup x:Name="PART_Popup" Focusable="false" AllowsTransparency="true" 
                               IsOpen="{Binding Path=IsDropDownOpen, 
                               RelativeSource={RelativeSource TemplatedParent}}" 
                               Placement="Bottom" 
                               PopupAnimation="{DynamicResource 
                                {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" >
                            <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" 
                                    MaxHeight="100" 
                                    MinWidth="{TemplateBinding ActualWidth}" 
                                    Color="Transparent">
                                <Border x:Name="DropDownBorder" CornerRadius="5"
                                        Background="Orange" 
                                        BorderBrush="Black" BorderThickness="2">
                                    <ScrollViewer Background="Orange">
                                        <ItemsPresenter 
                                            TextElement.FontSize="{TemplateBinding FontSize}"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                            KeyboardNavigation.DirectionalNavigation="Contained"/>
                                    </ScrollViewer>
                                </Border>
                            </Microsoft_Windows_Themes:SystemDropShadowChrome>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelectionBoxHighlighted" Value="true"/>
                                <Condition Property="IsDropDownOpen" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Foreground" Value="Black"/>
                        </MultiTrigger>

                        <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
                            <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
                            <Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
                        </Trigger>

                        <Trigger Property="HasItems" Value="false">
                            <Setter Property="MinHeight" TargetName="DropDownBorder" Value="95"/>
                        </Trigger>

                        <Trigger Property="IsGrouping" Value="true">
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                        </Trigger>

                        <Trigger Property="Tag" Value="BigCombo">
                            <Setter Property="ItemContainerStyle" Value="{StaticResource BigComboBox}"/>
                        </Trigger>


                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- GlassBtton-->
    <ControlTemplate x:Key="GlassButton" TargetType="{x:Type Button}">
        <ControlTemplate.Resources>
            <Storyboard x:Key="Timeline1">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="Timeline2">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </ControlTemplate.Resources>
        <Border BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4">
            <Border x:Name="border" Background="#7F000000" BorderBrush="#FF000000" BorderThickness="1,1,1,1" CornerRadius="4,4,4,4">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="0.507*"/>
                        <RowDefinition Height="0.493*"/>
                    </Grid.RowDefinitions>
                    <Border Opacity="0" HorizontalAlignment="Stretch" x:Name="glow" Width="Auto" Grid.RowSpan="2" CornerRadius="4,4,4,4">
                        <Border.Background>
                            <RadialGradientBrush>
                                <RadialGradientBrush.RelativeTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="1.702" ScaleY="2.243"/>
                                        <SkewTransform AngleX="0" AngleY="0"/>
                                        <RotateTransform Angle="0"/>
                                        <TranslateTransform X="-0.368" Y="-0.152"/>
                                    </TransformGroup>
                                </RadialGradientBrush.RelativeTransform>
                                <GradientStop Color="#B28DBDFF" Offset="0"/>
                                <GradientStop Color="#008DBDFF" Offset="1"/>
                            </RadialGradientBrush>
                        </Border.Background>
                    </Border>
                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Width="Auto" Grid.RowSpan="2"/>
                    <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="shine" Width="Auto" CornerRadius="4,4,0,0">
                        <Border.Background>
                            <LinearGradientBrush EndPoint="0.494,0.889" StartPoint="0.494,0.028">
                                <GradientStop Color="#99FFFFFF" Offset="0"/>
                                <GradientStop Color="#33FFFFFF" Offset="1"/>
                            </LinearGradientBrush>
                        </Border.Background>
                    </Border>
                </Grid>
            </Border>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Opacity" TargetName="shine" Value="0.4"/>
                <Setter Property="Background" TargetName="border" Value="#CC000000"/>
                <Setter Property="Visibility" TargetName="glow" Value="Hidden"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard x:Name="Timeline2_BeginStoryboard" Storyboard="{StaticResource Timeline2}"/>
                </Trigger.ExitActions>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    
    <!-- Media Player Buttons-->
    <ControlTemplate x:Key="MediaPlayerButtons" TargetType="{x:Type Button}">
        <Grid>
            <Ellipse x:Name="ellipse"  Width="{TemplateBinding Width}" 
											Height="{TemplateBinding Width}" 
                                             HorizontalAlignment="Center"
                                             VerticalAlignment="Center"
                                             Fill="Orange"
                                             Stroke="#FFFFA500" StrokeThickness="3">

            </Ellipse>
            <Label x:Name="lbl" 
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Content="{TemplateBinding Content}"
	                                    FontFamily="Webdings" FontSize="30" 
                                        Background="#00FBF7F7" 
	                                    Foreground="Black"/>
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"  Value="True">
                <Setter TargetName="lbl" Property="Foreground" Value="Orange"/>
            </Trigger>
            <Trigger Property="IsMouseOver"  Value="True">
                <Setter TargetName="ellipse" Property="Fill">
                    <Setter.Value>
                        <RadialGradientBrush>
                            <GradientStop Color="#FF000000" Offset="0"/>
                            <GradientStop Color="#FF4B4B4B" Offset="1"/>
                            <GradientStop Color="#FF333333" Offset="0.786"/>
                        </RadialGradientBrush>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </ControlTemplate.Triggers>

    </ControlTemplate>


</ResourceDictionary>

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)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)

- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence

Both of these at Sussex University UK.

Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2016
  • Codeproject MVP 2016
  • Microsoft C# MVP 2015
  • Codeproject MVP 2015
  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

Comments and Discussions