Click here to Skip to main content
15,894,646 members
Articles / Desktop Programming / WPF

WPF Explorer Bar

Rate me:
Please Sign up or sign in to vote.
4.67/5 (21 votes)
5 Oct 2008MIT3 min read 106.9K   2.6K   85  
A WPF explorer bar implementation.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:Odyssey.Controls"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Duration x:Key="animTime">0:0:0.4</Duration>
    <Style TargetType="{x:Type local:OdcExpander}">        
        <Setter Property="Background" Value="#40808080"/>
        <Setter Property="BorderBrush" Value="#60404040"/>
        <Setter Property="HeaderBackground" Value="#40A0A0A0"/>
        <Setter Property="MouseOverHeaderBackground" Value="#60FFFFFF"/>
        <Setter Property="MouseOverHeaderForeground" Value="#F0000000"/>
        <Setter Property="HeaderBorderThickness" Value="1"/>
        <Setter Property="CornerRadius" Value="0"/>
        <Setter Property="ShowEllipse" Value="True"/>
        <Setter Property="Padding" Value="8"/>
        <Setter Property="Template">          
            
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:OdcExpander}">
                    <Border>
                        <StackPanel>
                            <local:OdcExpanderHeader x:Name="header"  SnapsToDevicePixels="True"
                                                 BorderThickness="{TemplateBinding HeaderBorderThickness}"
                                                Content="{TemplateBinding Header}" 
                                                 IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsExpanded}"
                                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                Background="{TemplateBinding HeaderBackground}"
                                                BorderBrush="{TemplateBinding BorderBrush}"
                                                ShowEllipse="{TemplateBinding ShowEllipse}"
                                                CornerRadius="{TemplateBinding CornerRadius}"
                                                Image="{TemplateBinding Image}"/>
                            <local:AnimationDecorator Grid.Row="1"  SnapsToDevicePixels="True"
                                              Duration="{StaticResource animTime}"
                                              MinHeight="{TemplateBinding MinHeight}"
                                              MaxHeight="{TemplateBinding MaxHeight}"
                                              Height="{TemplateBinding Height}"
                                             IsExpanded="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsExpanded}">
                                <Border x:Name="panel"  Grid.Row="1" Padding="{TemplateBinding Padding}" 
                                        Background="{TemplateBinding Background}"
                                        BorderThickness="1,0,1,1"
                                        BorderBrush="{TemplateBinding BorderBrush}">
                                        <ContentPresenter 
                                              VerticalAlignment="Bottom"
                                              Content="{TemplateBinding Content}" 
                                              ContentTemplate="{TemplateBinding ContentTemplate}"/>                                    

                                </Border>
                            </local:AnimationDecorator>
                        </StackPanel>
                        <Border.LayoutTransform>
                            <ScaleTransform x:Name="scaleT" ScaleY="1"/>
                        </Border.LayoutTransform>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True" SourceName="header">
                            <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=MouseOverHeaderForeground}" TargetName="header"/>
                            <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=MouseOverHeaderBackground}" TargetName="header"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsPressed" Value="True" SourceName="header"/>
                                <Condition Property="HasPressedBackground" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=PressedHeaderBackground}" TargetName="header"/>
                        </MultiTrigger>
                        <EventTrigger RoutedEvent="local:OdcExpander.MaximizedEvent">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard Storyboard.TargetProperty="ScaleY" >
                                        <DoubleAnimation  To="1" Duration="{StaticResource animTime}" Storyboard.TargetName="scaleT" DecelerationRatio="0.8"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="local:OdcExpander.MinimizedEvent">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard Storyboard.TargetProperty="ScaleY" >
                                        <DoubleAnimation  To="0" Duration="{StaticResource animTime}" Storyboard.TargetName="scaleT" DecelerationRatio="0.8"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</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 MIT License


Written By
Software Developer (Senior)
Germany Germany
MCPD
Enterprise Application Developer 3.5
Windows Developer 3.5
.ASP.NET Developer 3.5
.NET 2.0 Windows Developer
.NET 2.0 Web Developer
.NET 2.0 Enterprise Application Developer


MCTS
.NET 3.5 Windows Forms Applications
.NET 3.5 ASP.NET Applications
.NET 3.5, ADO.NET Application Development
.NET 3.5 WCF
.NET 3.5 WPF
.NET 3.5 WF
Microsoft SQL Server 2008, Database Development
.NET 2.0 Windows Applications
.NET 2.0 Web Applications
.NET 2.0 Distributed Applications
SQL Server 2005
Sharepoint Services 3.0 Application Development
Windows Vista Client Configuration

Comments and Discussions