<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Office2016InspiredApplication" 
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    xmlns:appearance="clr-namespace:Office2016InspiredApplication.Appearance"
                    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"
                    xmlns:shell="clr-namespace:Telerik.Windows.Controls.RibbonView.Shell;assembly=Telerik.Windows.Controls.RibbonView">

    <Style x:Key="RadRibbonWindowCloseButtonStyle" TargetType="telerik:RadButton">
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Height" Value="30"/>
        <Setter Property="Width" Value="46"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:RadButton">
                    <Grid Background="{TemplateBinding Background}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MouseOverVisual"/>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="Path">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <SolidColorBrush Color="White" />
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MouseOverVisual"/>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PressedVisual"/>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="Path" >
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <SolidColorBrush Color="White" />
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="NormalVisual"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                CornerRadius="{TemplateBinding CornerRadius}"/>
                        <Border x:Name="PressedVisual"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}"
                                Opacity="0"
                                Background="#FFF1707A"/>
                        <Border x:Name="MouseOverVisual"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}"
                                Opacity="0"
                                Background="#FFE81123"/>
                        <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                            <Path x:Name="Path"
                                    Data="M1,0L5,4L9,0L10,1L6,5L10,9L9,10L5,6L1,10L0,9L4,5L0,1z"
                                    Fill="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="RadRibbonWindowMinimizeButtonStyle" TargetType="telerik:RadButton">
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Height" Value="30"/>
        <Setter Property="Width" Value="46"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:RadButton">
                    <Grid Background="{TemplateBinding Background}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MouseOverVisual"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PressedVisual"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="NormalVisual"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                CornerRadius="{TemplateBinding CornerRadius}"/>
                        <Border x:Name="PressedVisual"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}"
                                Opacity="0"
                                Background="{appearance:Office2016Resource Resource=PressedBackground}"/>
                        <Border x:Name="MouseOverVisual"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}"
                                Opacity="0"
                                Background="{appearance:Office2016Resource Resource=MouseOverBackground}"/>
                        <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                            <Path x:Name="Path"
                                    Data="M0,0 L10,0 L10,1 L0,1 z"
                                    Fill="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="RadRibbonWindowToggleButtonStyle" TargetType="telerik:RadToggleButton">
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Height" Value="30"/>
        <Setter Property="Width" Value="46"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:RadToggleButton">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MouseOverVisual"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PressedVisual"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard Duration="0">
                                        <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetName="ContentGrid" Storyboard.TargetProperty="Opacity"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="NormalVisual"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                CornerRadius="{TemplateBinding CornerRadius}"/>
                        <Border x:Name="PressedVisual"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}"
                                Opacity="0"
                               Background="{appearance:Office2016Resource Resource=PressedBackground}"/>
                        <Border x:Name="MouseOverVisual"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}"
                                Opacity="0"
                                Background="{appearance:Office2016Resource Resource=MouseOverBackground}"/>
                        <Grid x:Name="Restore" Background="Transparent" ToolTipService.ToolTip="Maximize">
                            <Grid.ToolTip>
                                <TextBlock Text="{telerik:LocalizableResource Key=RibbonWindowMaximize}"/>
                            </Grid.ToolTip>
                            <Path x:Name="MaximizedPath"
                                    Data="M0.9,0.9L0.9,8.9L9,8.9L9,0.9zM0,0L10,0L10,10L0,10z"
                                    Fill="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"/>
                        </Grid>
                        <Grid Visibility="Collapsed" x:Name="Collapse" Background="Transparent" ToolTipService.ToolTip="Restore Down" HorizontalAlignment="Center" VerticalAlignment="Center">
                            <Grid.ToolTip>
                                <TextBlock Text="{telerik:LocalizableResource Key=RibbonWindowRestoreDown}"/>
                            </Grid.ToolTip>
                            <Path x:Name="RestoredPath" Width="10" Height="10" Stretch="Fill"
                                    Data="M 1116,386 C1116,386 1111,386 1111,386 1111,386 1111,385 1111,385 1111,385 1117,385 1117,385 1117,385 1117,391 1117,391 1117,391 1116,391 1116,391 1116,391 1116,386 1116,386 zM 1109,387 C1109,387 1115,387 1115,387 1115,387 1115,393 1115,393 1115,393 1109,393 1109,393 1109,393 1109,387 1109,387 zM 1108,386 C1108,386 1108,394 1108,394 1108,394 1116,394 1116,394 1116,394 1116,392 1116,392 1116,392 1118,392 1118,392 1118,392 1118,384 1118,384 1118,384 1110,384 1110,384 1110,384 1110,386 1110,386 1110,386 1108,386 1108,386 z"
                                    Fill="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"/>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="Restore" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="Collapse" Property="Visibility" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="WindowTitleStyle" TargetType="telerikRibbonViewPrimitives:WindowTitle" BasedOn="{StaticResource WindowTitleStyle}">
        <Setter Property="Foreground" Value="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerikRibbonViewPrimitives:WindowTitle">
                    <telerikRibbonViewPrimitives:WindowTitlePanel>
                        <TextBlock x:Name="Title"
                                Text="{TemplateBinding Title}"
                                Foreground="{TemplateBinding Foreground}"
                                TextTrimming="CharacterEllipsis"
                                FontSize="{telerik:VisualStudio2013Resource ResourceKey=FontSize}"/>
                        <TextBlock x:Name="Divider"
                                Text="{telerik:LocalizableResource Key=RibbonViewWindowTitleDivider}"
                                Visibility="{TemplateBinding DividerVisibility}"
                                Foreground="{TemplateBinding Foreground}"
                                FontSize="{telerik:VisualStudio2013Resource ResourceKey=FontSize}"/>
                        <TextBlock x:Name="ApplicationName"
                                Text="{TemplateBinding ApplicationName}"
                                Foreground="{TemplateBinding Foreground}"
                                TextTrimming="CharacterEllipsis"
                                FontSize="{telerik:VisualStudio2013Resource ResourceKey=FontSize}"/>
                    </telerikRibbonViewPrimitives:WindowTitlePanel>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=telerikRibbonView:RadRibbonView}, Path=IsHostedInRibbonWindow}" Value="True">
                            <Setter TargetName="ApplicationName" Property="Foreground" Value="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}"/>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="telerikRibbonView:RadRibbonWindow" x:Key="RadRibbonWindowStyle">
        <Setter Property="TitleBarStyle" Value="{StaticResource WindowTitleStyle}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Background" Value="{telerik:VisualStudio2013Resource ResourceKey=HeaderBrush}" />
        <Setter Property="WindowBackground" Value="{telerik:VisualStudio2013Resource ResourceKey=MainBrush}"/>
        <Setter Property="BorderBrush" Value="{telerik:VisualStudio2013Resource ResourceKey=AccentBrush}"/>
        <Setter Property="shell:WindowChrome.WindowChromeCornerRadius" Value="0"/>
        <Setter Property="UseLayoutRounding" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerikRibbonView:RadRibbonWindow">
                    <Grid Background="Transparent">
                        <Border x:Name="outerBorder"
                                    Grid.ColumnSpan="3"
                                    Grid.RowSpan="3"
                                    Background="{TemplateBinding WindowBackground}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}">

                            <Grid x:Name="MaximizeWindowDecorator" >
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="30"/>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Border Grid.Row="0" Grid.RowSpan="3" Grid.Column="1" Background="{TemplateBinding WindowBackground}" BorderThickness="{TemplateBinding BorderThickness}"/>
                                <Grid Grid.ColumnSpan="3" Background="{TemplateBinding Background}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <StackPanel x:Name="IconPanel" Orientation="Horizontal" HorizontalAlignment="Left" Visibility="Collapsed" VerticalAlignment="Center" Margin="4 0 0 3">
                                        <Image Name="PART_Icon"
                                            shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                            Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Icon, Converter={StaticResource IconConverter}}"
                                            Width="{Binding Path=SmallIconSize.Width, Source={x:Static shell:SystemParameters2.Current}}"
                                            Height="{Binding Path=SmallIconSize.Height, Source={x:Static shell:SystemParameters2.Current}}"/>
                                        <Rectangle Width="1" Margin="4 0" Fill="{telerik:VisualStudio2013Resource ResourceKey=BasicBrush}"/>
                                    </StackPanel>
                                    <telerikRibbonViewPrimitives:WindowTitle x:Name="WindowTitle"
                                        Grid.Column="1"
                                        Title="{TemplateBinding Title}"
                                        Style="{TemplateBinding TitleBarStyle}"
                                        VerticalAlignment="Center"
                                        HorizontalAlignment="Center"
                                        Margin="0 0 65 0"/>
                                </Grid>
                                <StackPanel x:Name="buttonPanel" Orientation="Horizontal" Grid.ColumnSpan="3" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                                    <telerik:RadButton x:Name="minimizeButton"
                                        shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                        ToolTipService.ToolTip="Minimize"
                                        Command="{x:Static shell:SystemCommands.MinimizeWindowCommand}"
                                        Style="{StaticResource RadRibbonWindowMinimizeButtonStyle}">
                                        <telerik:RadButton.ToolTip>
                                            <TextBlock Text="{telerik:LocalizableResource Key=RibbonWindowMinimize}"/>
                                        </telerik:RadButton.ToolTip>
                                    </telerik:RadButton>
                                    <telerik:RadToggleButton x:Name="maximizeButton"
                                        shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                        IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=WindowState, Converter={StaticResource BooleanToWindowStateConverter}, Mode=TwoWay}"
                                        Style="{StaticResource RadRibbonWindowToggleButtonStyle}"/>
                                    <telerik:RadButton x:Name="closeButton"
                                        shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                        Command="{x:Static shell:SystemCommands.CloseWindowCommand}"
                                        Style="{StaticResource RadRibbonWindowCloseButtonStyle}">
                                        <telerik:RadButton.ToolTip>
                                            <TextBlock Text="{telerik:LocalizableResource Key=RibbonWindowClose}"/>
                                        </telerik:RadButton.ToolTip>
                                    </telerik:RadButton>
                                </StackPanel>

                                <Border x:Name="PART_ClientAreaBorder" Background="White" Grid.Column="1" Grid.Row="1"/>
                                <AdornerDecorator x:Name="Adorner" Grid.Column="1" Grid.RowSpan="2" >
                                    <ContentPresenter Canvas.ZIndex="0" Name="PART_RootContentPresenter"/>
                                </AdornerDecorator>
                                <ResizeGrip x:Name="WindowResizeGrip"
                                    Grid.Row="1"
                                    Grid.Column="1"
                                    shell:WindowChrome.ResizeGripDirection="BottomRight"
                                    HorizontalAlignment="Right"
                                    VerticalAlignment="Bottom"
                                    Visibility="Collapsed"
                                    IsTabStop="false"/>
                            </Grid>

                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Window.ResizeMode" Value="CanResizeWithGrip"/>
                                <Condition Property="Window.WindowState" Value="Normal"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible"/>
                        </MultiTrigger>
                        <Trigger Property="Window.ResizeMode" Value="NoResize">
                            <Setter TargetName="minimizeButton" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="maximizeButton" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="closeButton" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="WindowState" Value="Maximized">
                            <Setter TargetName="IconPanel" Property="Margin" Value="9 2 0 3"/>
                            <Setter TargetName="Adorner" Property="Margin" Value="0"/>
                            <Setter TargetName="MaximizeWindowDecorator" Property="Margin" Value="6"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="telerik:RadRibbonWindow.IsAutoHideTaskbar" Value="true"/>
                                <Condition Property="Window.WindowState" Value="Maximized"/>
                            </MultiTrigger.Conditions>
                            <Setter TargetName="MaximizeWindowDecorator" Property="Margin" Value="-7 -2 -7 -6"/>
                        </MultiTrigger>
                        <Trigger Property="IsTitleVisible" Value="False">
                            <Setter TargetName="WindowTitle" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:MainWindow" BasedOn="{StaticResource RadRibbonWindowStyle}" />
</ResourceDictionary>