<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="ExpanderHeaderFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border>
                        <Rectangle
                            Margin="0"
                            SnapsToDevicePixels="true"
                            Stroke="Black"
                            StrokeDashArray="1 2"
                            StrokeThickness="1" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <SolidColorBrush x:Key="Expander_Header_BG" Color="#FF439BD8" />
    <SolidColorBrush x:Key="Expander_Header_BD" Color="Black" />
    <SolidColorBrush x:Key="Expander_Header_BG_HighLight" Color="#FFD6E4FF" />
    <SolidColorBrush x:Key="Expander_InnerHighlight" Color="#FF9FCDED" />
    <SolidColorBrush x:Key="Expander_InnerShadow" Color="#FF003A62" />
    <SolidColorBrush x:Key="Expander_BG_MouseOver" Color="#FF227BB8" />

    <Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="FontSize" Value="14" />
        <Setter Property="MinWidth" Value="100" />
        <Setter Property="FontFamily" Value="Arial" />
        <Setter Property="BorderBrush" Value="{DynamicResource Expander_Header_BD}" />
        <Setter Property="Background" Value="{DynamicResource Expander_Header_BG}" />
        <Setter Property="Foreground" Value="{DynamicResource FG_White}" />
        <Setter Property="Border.CornerRadius" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid Background="Transparent" Cursor="Hand">
                        <Border
                            x:Name="OuterBorder"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="0"
                            CornerRadius="{TemplateBinding Border.CornerRadius}">
                            <Border
                                x:Name="InnerBD_Highlight"
                                BorderBrush="{DynamicResource Expander_InnerHighlight}"
                                BorderThickness="2,2,0,0"
                                CornerRadius="4">
                                <Border
                                    x:Name="InnerBD_Shadow"
                                    Padding="3"
                                    BorderBrush="{DynamicResource Expander_InnerShadow}"
                                    BorderThickness="0,0,2,2"
                                    CornerRadius="4">
                                    <Grid SnapsToDevicePixels="False">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="17" />
                                        </Grid.ColumnDefinitions>
                                        <Grid Grid.Column="1">
                                            <Ellipse
                                                Width="15"
                                                Height="15"
                                                Stroke="{DynamicResource Expander_InnerHighlight}"
                                                StrokeThickness="1" />
                                            <Rectangle
                                                x:Name="Path1"
                                                Width="9"
                                                Height="2"
                                                Fill="White" />
                                            <Rectangle
                                                x:Name="Path2"
                                                Width="2"
                                                Height="9"
                                                Fill="White" />
                                        </Grid>
                                        <ContentPresenter
                                            Margin="5,0"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Center"
                                            RecognizesAccessKey="True"
                                            SnapsToDevicePixels="True" />
                                    </Grid>
                                </Border>
                            </Border>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter TargetName="Path2" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="OuterBorder" Property="Border.CornerRadius" Value="5,5,0,0" />
                            <Setter TargetName="InnerBD_Highlight" Property="Border.CornerRadius" Value="4,4,0,0" />
                            <Setter TargetName="InnerBD_Shadow" Property="Border.CornerRadius" Value="4,4,0,0" />
                            <Setter TargetName="InnerBD_Shadow" Property="BorderThickness" Value="0,0,2,0" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource Expander_BG_MouseOver}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource Expander_BG_MouseOver}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ExpanderRightHeaderStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="FontSize" Value="14" />
        <Setter Property="FontFamily" Value="Arial" />
        <Setter Property="Foreground" Value="{DynamicResource FG_Black}" />
        <Setter Property="Background" Value="{DynamicResource Expander_Header_BG}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Expander_Header_BD}" />
        <Setter Property="Border.CornerRadius" Value="2" />
        <Setter Property="Opacity" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid Background="Transparent" Cursor="Hand">
                        <Grid.LayoutTransform>
                            <TransformGroup>
                                <TransformGroup.Children>
                                    <TransformCollection>
                                        <RotateTransform Angle="-90" />
                                    </TransformCollection>
                                </TransformGroup.Children>
                            </TransformGroup>
                        </Grid.LayoutTransform>
                        <Grid Margin="0,5" SnapsToDevicePixels="False">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="17" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Border
                                x:Name="OuterBorder"
                                Grid.Column="0"
                                Width="15"
                                Height="15"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center"
                                Background="{DynamicResource Expander_Header_BG}"
                                BorderBrush="{DynamicResource Expander_Header_BD}"
                                BorderThickness="1"
                                CornerRadius="2">
                                <Grid>
                                    <Rectangle
                                        x:Name="Path1"
                                        Width="9"
                                        Height="2"
                                        Fill="White">
                                        <Rectangle.LayoutTransform>
                                            <TransformGroup>
                                                <TransformGroup.Children>
                                                    <TransformCollection>
                                                        <RotateTransform Angle="-90" />
                                                    </TransformCollection>
                                                </TransformGroup.Children>
                                            </TransformGroup>
                                        </Rectangle.LayoutTransform>
                                    </Rectangle>
                                    <Rectangle
                                        x:Name="Path2"
                                        Width="2"
                                        Height="9"
                                        Fill="White">
                                        <Rectangle.LayoutTransform>
                                            <TransformGroup>
                                                <TransformGroup.Children>
                                                    <TransformCollection>
                                                        <RotateTransform Angle="-90" />
                                                    </TransformCollection>
                                                </TransformGroup.Children>
                                            </TransformGroup>
                                        </Rectangle.LayoutTransform>
                                    </Rectangle>
                                </Grid>
                            </Border>
                            <ContentPresenter
                                Grid.Column="1"
                                Margin="5,0"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                RecognizesAccessKey="True"
                                SnapsToDevicePixels="True" />
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter TargetName="Path2" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource Expander_Header_BG_HighLight}" />
                            <Setter TargetName="Path1" Property="Fill" Value="Black" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true" />
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource Expander_Header_BG_HighLight}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Expander}">
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Grid>
                        <DockPanel>
                            <ToggleButton
                                x:Name="HeaderSite"
                                MinWidth="0"
                                MinHeight="0"
                                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                Content="{TemplateBinding Header}"
                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                DockPanel.Dock="Top"
                                FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}"
                                IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                Style="{StaticResource ExpanderDownHeaderStyle}" />
                            <ContentPresenter
                                x:Name="ExpandSite"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                DockPanel.Dock="Bottom"
                                Focusable="false"
                                Visibility="Collapsed" />
                        </DockPanel>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="true">
                            <Setter TargetName="ExpandSite" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Right">
                            <Setter TargetName="ExpandSite" Property="DockPanel.Dock" Value="Right" />
                            <Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Left" />
                            <Setter TargetName="HeaderSite" Property="Style" Value="{StaticResource ExpanderRightHeaderStyle}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>