<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:hc="clr-namespace:HandyControl.Controls">

    <Style x:Key="MenuItem4FrameStyle" BasedOn="{StaticResource MenuItemBaseStyle}" TargetType="MenuItem">
        <Setter Property="Header" Value="{Binding (JournalEntry.Name)}"/>
        <Setter Property="Command" Value="NavigationCommands.NavigateJournal"/>
        <Setter Property="CommandTarget" Value="{Binding TemplatedParent, RelativeSource={RelativeSource AncestorType=ContextMenu}}"/>
        <Setter Property="CommandParameter" Value="{Binding RelativeSource={RelativeSource Self}}"/>
    </Style>

    <ControlTemplate x:Key="FrameWithNavigationUIStyle" TargetType="Frame">
        <Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
            <DockPanel LastChildFill="True">
                <Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter}, ConverterParameter='1,1,0,0'}" DockPanel.Dock="Top" BorderThickness="0,0,0,1" BorderBrush="{TemplateBinding BorderBrush}" Background="{DynamicResource DarkDefaultBrush}">
                    <hc:ButtonGroup x:Name="NavChrome" Width="90" Margin="10,6" HorizontalAlignment="Left">
                        <Button Padding="6" hc:IconElement.Geometry="{StaticResource LeftGeometry}" Command="NavigationCommands.BrowseBack">
                            <Button.ContextMenu>
                                <ContextMenu x:Name="BackNavMenu" ItemContainerStyle="{StaticResource MenuItem4FrameStyle}" ItemsSource="{Binding Path=(NavigationWindow.BackStack), RelativeSource={RelativeSource TemplatedParent}}"/>
                            </Button.ContextMenu>
                        </Button>
                        <Button Padding="6" hc:IconElement.Geometry="{StaticResource RightGeometry}" Command="NavigationCommands.BrowseForward">
                            <Button.ContextMenu>
                                <ContextMenu x:Name="ForwardNavMenu" ItemContainerStyle="{StaticResource MenuItem4FrameStyle}" ItemsSource="{Binding Path=(NavigationWindow.ForwardStack), RelativeSource={RelativeSource TemplatedParent}}"/>
                            </Button.ContextMenu>
                        </Button>
                        <Button Padding="6" hc:IconElement.Geometry="{StaticResource RotateRightGeometry}" Command="NavigationCommands.Refresh"/>
                    </hc:ButtonGroup>
                </Border>
                <ContentPresenter SnapsToDevicePixels="True" x:Name="PART_NavWinCP" ClipToBounds="true"/>
            </DockPanel>
        </Border>
    </ControlTemplate>

    <Style x:Key="FrameBaseStyle" TargetType="Frame">
        <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Frame">
                    <Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                        <ContentPresenter SnapsToDevicePixels="True" x:Name="PART_FrameCP"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="NavigationUIVisibility" Value="Visible">
                <Setter Property="Template" Value="{StaticResource FrameWithNavigationUIStyle}"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="JournalOwnership" Value="OwnsJournal"/>
                    <Condition Property="NavigationUIVisibility" Value="Automatic"/>
                </MultiTrigger.Conditions>
                <Setter Property="Template" Value="{StaticResource FrameWithNavigationUIStyle}"/>
            </MultiTrigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>
