<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    xmlns:appearance="clr-namespace:Office2016InspiredApplication.Appearance"
                    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
                    xmlns:telerikToolBar="clr-namespace:Telerik.Windows.Controls.ToolBar;assembly=Telerik.Windows.Controls.Navigation"          
                    xmlns:telerikRibbonView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.RibbonView"
                    xmlns:telerikRibbonViewPrimitives="clr-namespace:Telerik.Windows.Controls.RibbonView.Primitives;assembly=Telerik.Windows.Controls.RibbonView">

    <Style TargetType="telerikRibbonView:RadButtonGroupItem" BasedOn="{StaticResource RadButtonGroupItemStyle}">
        <Setter Property="BorderThickness" Value="0" />
    </Style>

    <Style TargetType="telerikRibbonView:RadButtonGroup" BasedOn="{StaticResource RadButtonGroupStyle}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderThickness" Value="0 0 1 0" />
    </Style>

    <!--Quick Styles Gallery Item-->
    <ControlTemplate x:Key="RadGalleryItemTemplate" TargetType="telerikRibbonView:RadGalleryItem">
        <Grid>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="Border">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="SelectedMouseOver"/>
                </VisualStateGroup>
                <VisualStateGroup x:Name="SelectionStates">
                    <VisualState x:Name="Unselected"/>
                    <VisualState x:Name="Selected">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Background_Selected"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="HeaderStates">
                    <VisualState x:Name="IsNotHeader"/>
                    <VisualState x:Name="IsHeader">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Header_Background"/>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderThickness">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Thickness>0</Thickness>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="contentControl" Storyboard.TargetProperty="HorizontalAlignment">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <HorizontalAlignment>Left</HorizontalAlignment>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="Margin">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Thickness>5 0 0 0</Thickness>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="KeyboardNavigationStates">
                    <VisualState x:Name="KeyboardUnfocused"/>
                    <VisualState x:Name="KeyboardFocused">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="KeyboardNavigationVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="Header_Background" Opacity="0" Background="{telerik:VisualStudio2013Resource ResourceKey=PrimaryBrush}"/>
            <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                <Grid Margin="{TemplateBinding Padding}">
                    <ContentControl x:Name="contentControl"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            Content="{TemplateBinding Content}"
                            IsTabStop="False"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            Foreground="{TemplateBinding Foreground}"
                            ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
                            ContentStringFormat="{TemplateBinding ContentStringFormat}"/>
                    <Image x:Name="Image"
                            Stretch="None"
                            Source="{TemplateBinding Image}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </Grid>
            </Border>
            <Border x:Name="Background_Selected"
                    Opacity="0"
                    Background="{x:Null}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    BorderBrush="{telerik:VisualStudio2013Resource ResourceKey=AccentDarkBrush}" />
            <Border x:Name="KeyboardNavigationVisual"
                    Opacity="0"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    BorderBrush="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}" />
        </Grid>
    </ControlTemplate>
    
    <Style TargetType="telerikRibbonView:RadGalleryItem" BasedOn="{StaticResource RadGalleryItemStyle}">
        <Setter Property="Padding" Value="0" />
        <Setter Property="Template" Value="{StaticResource RadGalleryItemTemplate}" />
    </Style>

    <Style TargetType="telerikRibbonView:RadRibbonGallery" BasedOn="{StaticResource RadRibbonGalleryStyle}" >
        <Setter Property="ViewportWidth" Value="440" />
        <Setter Property="PopupViewportWidth" Value="440" />
        <Setter Property="PopupViewportHeight" Value="120" />
    </Style>
    
    <Style TargetType="telerikRibbonView:RadGallery" BasedOn="{StaticResource RadGalleryStyle}">
        <Setter Property="Background" Value="White" />
    </Style>

    <ControlTemplate x:Key="ApplicationDropDownButtonTemplate" TargetType="telerikRibbonViewPrimitives:RadRibbonApplicationDropDownButton">
        <Grid>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetName="BackgroundBorder" Storyboard.TargetProperty="Opacity"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetName="BackgroundBorder" Storyboard.TargetProperty="Opacity"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="0.2" Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="Opacity"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="IsOpenState">
                    <VisualState x:Name="Closed"/>
                    <VisualState x:Name="Opened">
                        <Storyboard>
                            <DoubleAnimation Duration="00:00:00.1" Storyboard.TargetName="isOpenIndicator" Storyboard.TargetProperty="Opacity" To="1"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="KeyboardNavigationStates">
                    <VisualState x:Name="KeyboardUnfocused"/>
                    <VisualState x:Name="KeyboardFocused">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="KeyboardNavigationVisual" Storyboard.TargetProperty="Opacity" To="0.75" Duration="0"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"/>
            <Border x:Name="BackgroundBorder" BorderBrush="{appearance:Office2016Resource Resource=TabMouseOverBackground}" 
                    Background="{appearance:Office2016Resource Resource=TabMouseOverBackground}" Opacity="0"/>
            <Border x:Name="isOpenIndicator"
                    Opacity="0"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"/>
            <Border x:Name="KeyboardNavigationVisual"
                    Opacity="0"
                    Background="{x:Null}"
                    BorderBrush="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}"
                    BorderThickness="1"
                    Margin="1"/>
            <Grid x:Name="ContentGrid" Margin="{TemplateBinding Padding}">
                <ContentPresenter
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        Content="{TemplateBinding Content}"
                        ContentTemplate="{TemplateBinding ContentTemplate}"/>
            </Grid>
            <Popup x:Name="DropDownPopup" VerticalOffset="-1" AllowsTransparency="True" StaysOpen="True" Focusable="False">
                <Border x:Name="DropDownPopupBorder">
                    <ContentControl x:Name="DropDownPopupContent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="{TemplateBinding DropDownContent}"/>
                </Border>
            </Popup>
        </Grid>
    </ControlTemplate>

    <Style x:Key="ApplicationDropDownButtonStyle" TargetType="telerikRibbonViewPrimitives:RadRibbonApplicationDropDownButton" BasedOn="{StaticResource RadRibbonApplicationDropDownButtonStyle}">
        <Setter Property="Background" Value="{appearance:Office2016Resource Resource=ApplicationButtonBackground}" />
        <Setter Property="BorderBrush" Value="{appearance:Office2016Resource Resource=ApplicationButtonBackground}" />
        <Setter Property="MinWidth" Value="58" />
        <Setter Property="Padding" Value="13 4" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Template" Value="{StaticResource ApplicationDropDownButtonTemplate}" />
    </Style>

    <ControlTemplate x:Key="MinimizeButtonTemplate" TargetType="telerikRibbonView:RadRibbonToggleButton">
        <Grid x:Name="RootElement">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="OuterBorder">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="OuterBorder">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{telerik:VisualStudio2013Resource ResourceKey=AccentDarkBrush}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="arrow" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="CheckStates">
                    <VisualState x:Name="Unchecked">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootElement" Storyboard.TargetProperty="(telerikRibbonView:ScreenTip.Title)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{telerik:LocalizableResource Key=RibbonViewMinimizeRibbon}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Checked">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="arrow" Storyboard.TargetProperty="Opacity" To="0" Duration="0"/>
                            <DoubleAnimation Storyboard.TargetName="dockingIcon" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootElement" Storyboard.TargetProperty="(telerikRibbonView:ScreenTip.Title)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{telerik:LocalizableResource Key=RibbonViewExpandRibbon}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="KeyboardNavigationStates">
                    <VisualState x:Name="KeyboardUnfocused"/>
                    <VisualState x:Name="KeyboardFocused">
                        <Storyboard>
                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="KeyboardNavigationVisual"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="OuterBorder" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"/>
            <Border x:Name="KeyboardNavigationVisual"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Opacity="0"
                    Background="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}"
                    BorderBrush="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}"/>
            <Path x:Name="arrow"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"
                    Data="M0,0 L3,0 6,3 9,0 12,0 6,6 z"
                    RenderTransformOrigin="0.5 0.5"
                    Stretch="None"
                    Fill="{telerik:VisualStudio2013Resource ResourceKey=StrongBrush}"
                    StrokeThickness="0"
                    Width="12"
                    Height="6">
                <Path.RenderTransform>
                    <RotateTransform Angle="180" />
                </Path.RenderTransform>
            </Path>
            <Path x:Name="dockingIcon" Stretch="None" Opacity="0" Stroke="{telerik:VisualStudio2013Resource ResourceKey=StrongBrush}" StrokeThickness="1" Width="10" Height="7" 
                  Data="M3.5,0 L3.5,7 M3.5,1.5 L8.5,1.5 L9.5,2.5 L9.5,4.5 L8.5,5.5 L3.5,5.5 M3.5,3.5 L0,3.5 M3.5,4.5 L9.5,4.5" />
        </Grid>
    </ControlTemplate>

    <Style x:Key="MinimizeButtonStyle" TargetType="telerikRibbonView:RadRibbonToggleButton" BasedOn="{StaticResource MinimizeButtonStyle}">
        <Setter Property="Template" Value="{StaticResource MinimizeButtonTemplate}"/>
    </Style>

    <ControlTemplate x:Key="RadRibbonTabTemplate" TargetType="telerikRibbonView:RadRibbonTab">
        <Grid x:Name="RootPanel">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NormalVisual" Storyboard.TargetProperty="Background">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{appearance:Office2016Resource Resource=TabMouseOverBackground}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NormalVisual" Storyboard.TargetProperty="BorderBrush">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{appearance:Office2016Resource Resource=TabMouseOverBorderBrush}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="SelectionStates">
                    <VisualState x:Name="Selected">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderElement" Storyboard.TargetProperty="Foreground">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{appearance:Office2016Resource Resource=TabSelectedForeground}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SelectedVisual" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="NotSelected">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SelectedVisual" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="ContextualTabStates">
                    <VisualState x:Name="NotContextualTab">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="ActiveContextualTab">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="InactiveContextualTab">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="KeyboardNavigationStates">
                    <VisualState x:Name="KeyboardUnfocused"/>
                    <VisualState x:Name="KeyboardFocused">
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="KeyboardNavigationVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Rectangle x:Name="TabSeparator" Margin="0 0 -3 0" HorizontalAlignment="Right" Fill="{TemplateBinding BorderBrush}" VerticalAlignment="Stretch" Width="1" Visibility="Collapsed"/>
            <Grid x:Name="HeaderPanel" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HeaderVisibility, Mode=TwoWay}">
                <Border x:Name="NormalVisual" Margin="0 0 0 1" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" />
                <Border x:Name="SelectedVisual"
                        BorderThickness="1 1 1 0"
                        Visibility="Collapsed"
                        Background="{telerik:VisualStudio2013Resource ResourceKey=PrimaryBrush}"
                        BorderBrush="{telerik:VisualStudio2013Resource ResourceKey=BasicBrush}"/>
                <ContentControl x:Name="HeaderElement"
                        Content="{TemplateBinding Header}"
                        IsTabStop="False"
                        ContentTemplate="{TemplateBinding HeaderTemplate}"
                        Foreground="{TemplateBinding Foreground}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        Margin="{TemplateBinding Padding}"
                        ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                        ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>
            </Grid>
            <Grid x:Name="ContentPanel" Width="0" Height="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Border Name="OuterBorder" Grid.ColumnSpan="2"
                        BorderThickness="1"
                        Background="{telerik:VisualStudio2013Resource ResourceKey=PrimaryBrush}"
                        BorderBrush="{telerik:VisualStudio2013Resource ResourceKey=BasicBrush}"/>
                <telerikRibbonViewPrimitives:RibbonScrollViewer x:Name="TabItemsScrollViewer">
                    <ItemsPresenter HorizontalAlignment="Left" Margin="2" />
                </telerikRibbonViewPrimitives:RibbonScrollViewer>
                <telerikRibbonView:RadRibbonToggleButton x:Name="MinimizeButton" Width="30" Grid.Column="1"
                            Style="{StaticResource MinimizeButtonStyle}" VerticalAlignment="Bottom" Margin="1"
                            IsEnabled="{Binding IsMinimizable, RelativeSource={RelativeSource AncestorType=telerik:RadRibbonView}}"
                            IsChecked="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadRibbonView}, Path=IsMinimized, Mode=TwoWay}" />
            </Grid>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{appearance:Office2016Resource Resource=TabMouseOverForeground}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="telerik:RadRibbonTab" BasedOn="{StaticResource RadRibbonTabStyle}">
        <Setter Property="BorderThickness" Value="1 1 1 0" />
        <Setter Property="Padding" Value="13 4"/>
        <Setter Property="Foreground" Value="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}" />
        <Setter Property="Template" Value="{StaticResource RadRibbonTabTemplate}"/>
    </Style>

    <ControlTemplate x:Key="RadRibbonGroupDropDownButtonTemplate" TargetType="telerikRibbonView:RadRibbonDropDownButton">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal"/>
                    <VisualState x:Name="MouseOver">
                        <Storyboard>
                            <DoubleAnimation Duration="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MouseOverVisual" To="1"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Pressed">
                        <Storyboard>
                            <DoubleAnimation Duration="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PressedVisual" To="1"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Disabled">
                        <Storyboard Duration="0">
                            <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="Opacity"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="FocusState">
                    <VisualState x:Name="Focused"/>
                    <VisualState x:Name="Unfocused"/>
                </VisualStateGroup>
                <VisualStateGroup x:Name="IsOpenState">
                    <VisualState x:Name="Closed">
                        <Storyboard/>
                    </VisualState>
                    <VisualState x:Name="Opened">
                        <Storyboard>
                            <DoubleAnimation Duration="0" Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Opacity" To="1"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="DropDownPlacementState">
                    <VisualState x:Name="PlacementBottom"/>
                    <VisualState x:Name="PlacementTop"/>
                    <VisualState x:Name="PlacementLeft"/>
                    <VisualState x:Name="PlacementRight"/>
                </VisualStateGroup>
                <VisualStateGroup x:Name="DropDownContentState">
                    <VisualState x:Name="HasDropDownContent"/>
                    <VisualState x:Name="WithoutDropDownContent">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DropDownIndicator">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
                <VisualStateGroup x:Name="DropShadowVisibilityState">
                    <VisualState x:Name="HasShadow"/>
                    <VisualState x:Name="WithoutShadow"/>
                </VisualStateGroup>
                <VisualStateGroup x:Name="KeyboardNavigationStates">
                    <VisualState x:Name="KeyboardUnfocused"/>
                    <VisualState x:Name="KeyboardFocused">
                        <Storyboard>
                            <DoubleAnimation Duration="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="KeyboardNavigationVisual" To="1"/>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border x:Name="NormalVisual" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"/>
            <Border x:Name="MouseOverVisual" Opacity="0" Background="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}"/>
            <Border x:Name="PressedVisual" Opacity="0" Background="{telerik:VisualStudio2013Resource ResourceKey=AccentDarkBrush}"/>
            <Border x:Name="KeyboardNavigationVisual" Opacity="0" Background="{telerik:VisualStudio2013Resource ResourceKey=SemiBasicBrush}"/>
            <Grid Margin="{TemplateBinding Padding}" x:Name="ContentGrid" VerticalAlignment="Center">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="ContentPresenter"
                        Content="{TemplateBinding Content}"
                        ContentTemplate="{TemplateBinding ContentTemplate}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        RecognizesAccessKey="True"/>
                <Border x:Name="Image"
                        Margin="3"
                        Background="{telerik:VisualStudio2013Resource ResourceKey=MainBrush}"
                        BorderBrush="{telerik:VisualStudio2013Resource ResourceKey=BasicBrush}"
                        BorderThickness="1"
                        Width="32"
                        Height="32">
                    <Grid>
                        <Image VerticalAlignment="Center" HorizontalAlignment="Center" Source="{TemplateBinding SmallImage}" Stretch="None" Width="16" Height="16"/>
                    </Grid>
                </Border>
                <TextBlock Name="textRow1" Grid.Row="1" Text="{TemplateBinding TextRow1}" TextAlignment="Center" Foreground="{TemplateBinding Foreground}"/>
                <StackPanel Name="DropDownPanel" Grid.Row="2" HorizontalAlignment="Center" Orientation="Horizontal" Margin="0 5 0 0">
                    <TextBlock Name="textRow2" Text="{TemplateBinding TextRow2}" Foreground="{TemplateBinding Foreground}"/>
                    <Path
                            Name="DropDownIndicator"
                            IsHitTestVisible="False"
                            Visibility="{TemplateBinding DropDownIndicatorVisibility}"
                            Margin="2"
                            VerticalAlignment="Top"
                            HorizontalAlignment="Center"
                            Fill="{telerik:VisualStudio2013Resource ResourceKey=StrongBrush}"
                            Data="M0,0L6,0L3,4z"
                            SnapsToDevicePixels="True"/>
                </StackPanel>
            </Grid>
            <Popup x:Name="DropDownPopup"
                    AllowsTransparency="True"
                    StaysOpen="False"
                    Focusable="False"
                    Placement="Bottom"
                    IsOpen="{Binding Path=IsOpen, RelativeSource={RelativeSource TemplatedParent}}">
                <Grid>
                    <Border x:Name="DropDownPopupBorder"
                            Padding="0"
                            Margin="0"
                            MinWidth="3"
                            MinHeight="3"
                            Width="{TemplateBinding DropDownWidth}"
                            Height="{TemplateBinding DropDownHeight}"
                            MaxWidth="{TemplateBinding DropDownMaxWidth}"
                            MaxHeight="{TemplateBinding DropDownMaxHeight}"
                            Background="{telerik:VisualStudio2013Resource ResourceKey=PrimaryBrush}"
                            BorderBrush="{telerik:VisualStudio2013Resource ResourceKey=BasicBrush}"
                            BorderThickness="1">
                        <ContentControl x:Name="DropDownPopupContent"
                                Content="{TemplateBinding DropDownContent}"
                                ContentTemplate="{TemplateBinding DropDownContentTemplate}"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                VerticalContentAlignment="Stretch"
                                DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext}"/>
                    </Border>
                </Grid>
            </Popup>
        </Grid>
    </ControlTemplate>

    <Style x:Key="RadRibbonGroupDropDownButtonStyle" TargetType="telerikRibbonView:RadRibbonDropDownButton" BasedOn="{StaticResource RadRibbonGroupDropDownButtonStyle}">
        <Setter Property="Template" Value="{StaticResource RadRibbonGroupDropDownButtonTemplate}" />
    </Style>

    <Style TargetType="telerikRibbonView:RadRibbonGroup" BasedOn="{StaticResource RadRibbonGroupStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerikRibbonView:RadRibbonGroup">
                    <Grid SnapsToDevicePixels="True">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="SizeState">
                                <VisualState x:Name="Expanded"/>
                                <VisualState x:Name="Collapsed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CollapsedButton" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CollapsedGroup">
                                <VisualState x:Name="CollapsedGroupNormal"/>
                                <VisualState x:Name="CollapsedGroupPushed"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <telerikRibbonViewPrimitives:GroupChrome x:Name="ExpandedChrome"
                             Foreground="{TemplateBinding Foreground}"
                             DialogLauncherCommand="{TemplateBinding DialogLauncherCommand}"
                             DialogLauncherCommandParameter="{TemplateBinding DialogLauncherCommandParameter}"
                             DialogLauncherCommandTarget="{TemplateBinding DialogLauncherCommandTarget}"
                             Header="{TemplateBinding Header}"
                             HeaderTemplate="{TemplateBinding HeaderTemplate}"
                             DialogLauncherVisibility="{TemplateBinding DialogLauncherVisibility}"
                             IsTabStop="False"
                             HeaderStringFormat="{TemplateBinding HeaderStringFormat}"
                             Margin="0 0 -1 0">
                            <ItemsPresenter Name="ItemsPresenter"/>
                        </telerikRibbonViewPrimitives:GroupChrome>
                        <telerikRibbonView:RadRibbonDropDownButton x:Name="CollapsedButton"
                                Visibility="Collapsed"
                                Style="{StaticResource RadRibbonGroupDropDownButtonStyle}"
                                SplitText="False"
                                SmallImage="{TemplateBinding Icon}"
                                Size="Large"
                                Text="{TemplateBinding Header}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="RadRibbonViewTemplate" TargetType="telerikRibbonView:RadRibbonView">
        <Grid x:Name="RootPanel">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Rectangle x:Name="outerRectangle" Grid.Row="1" Grid.RowSpan="2" Fill="{TemplateBinding Background}" />
            <ContentPresenter x:Name="SelectedTabContent" Grid.Row="1" Height="{TemplateBinding ContentHeight}" />
            <Grid x:Name="TopGrid" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Border x:Name="titleBarBackground" Background="{TemplateBinding TitleBarBackground}" IsHitTestVisible="False" Grid.ColumnSpan="3"/>
                <Rectangle Grid.Row="1" Grid.ColumnSpan="3" Fill="{TemplateBinding TitleBarBackground}"/>
                <telerikRibbonViewPrimitives:RibbonTitleBarPanel x:Name="RibbonTitleBarPanel" Grid.ColumnSpan="2" Visibility="{TemplateBinding TitleBarVisibility}">
                    <ContentPresenter x:Name="AboveToolBarHost" VerticalAlignment="Center" telerikRibbonViewPrimitives:RibbonTitleBarPanel.Element="QuickAccessToolBar"/>
                    <telerikRibbonViewPrimitives:WindowTitle x:Name="WindowTitle" Margin="0 6 40 6"
                            Title="{TemplateBinding Title}" Foreground="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}"
                            telerikRibbonViewPrimitives:RibbonTitleBarPanel.Element="WindowTitle"
                            ApplicationName="{TemplateBinding ApplicationName}"
                            Style="{TemplateBinding WindowTitleStyle}"/>
                    <StackPanel x:Name="ContextualGroupsHeaders" Margin="1 0 0 0" Orientation="Horizontal" telerikRibbonViewPrimitives:RibbonTitleBarPanel.Element="ContextualGroupsPanel"/>
                </telerikRibbonViewPrimitives:RibbonTitleBarPanel>
                <telerikRibbonViewPrimitives:RadRibbonApplicationDropDownButton x:Name="ApplicationButton" Margin="0 5 1 0"
                        Grid.Row="1"
                        IsEnabled="{TemplateBinding IsApplicationButtonEnabled}"
                        IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsApplicationMenuOpen, Mode=TwoWay}"
                        SmallImage="{TemplateBinding ApplicationButtonImageSource}"
                        Content="{TemplateBinding ApplicationButtonContent}"
                        Visibility="{TemplateBinding ApplicationButtonVisibility}"
                        Style="{DynamicResource ApplicationDropDownButtonStyle}" />
                <telerikRibbonViewPrimitives:RibbonScrollViewer Grid.Column="1" Grid.Row="1" Margin="0 5 0 -1" x:Name="TabsScrollViewer">
                    <ItemsPresenter/>
                </telerikRibbonViewPrimitives:RibbonScrollViewer>
                <Rectangle Fill="Transparent" VerticalAlignment="Bottom" Height="2" Margin="0 0 0 -1" Grid.ColumnSpan="3" Grid.RowSpan="2"/>
            </Grid>
            <ContentPresenter x:Name="BelowToolBarHost" Grid.Row="2" />
            <Popup x:Name="TabContentPopup" VerticalOffset="-1" PlacementTarget="{Binding ElementName=TopGrid}" AllowsTransparency="True">
                <Border Background="{TemplateBinding Background}">
                    <ContentPresenter x:Name="SelectedTabContentPopup" Height="{TemplateBinding ContentHeight}" />
                </Border>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsHostedInRibbonWindow" Value="true">
                <Setter TargetName="titleBarBackground" Property="Visibility" Value="Collapsed"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="RibbonViewOffice2016Style" TargetType="telerikRibbonView:RadRibbonView" BasedOn="{StaticResource RadRibbonViewStyle}">
        <Setter Property="TitleBarBackground" Value="{telerik:VisualStudio2013Resource ResourceKey=HeaderBrush}"/>
        <Setter Property="Template" Value="{StaticResource RadRibbonViewTemplate}" />
    </Style>

    <Style TargetType="telerikRibbonView:RadRibbonView" BasedOn="{StaticResource RibbonViewOffice2016Style}" />
</ResourceDictionary>
