简体   繁体   中英

Ribbon Office 2013 template

I am using the following code to try my application has the same format as Office 2013, you must only add the reference to the project that comes with WPF 4.5 and is System.Windows.Controls.Ribbon. I have a problem, I need that when you select a tab, the line that is missing is complete, attached a picture:

在此处输入图片说明

<Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            WindowStartupLocation="CenterScreen">

        <Window.Resources>

            <Style TargetType="Ribbon">
                <Setter Property="Background" Value="White"/>
                <Setter Property="Foreground" Value="Black"/>
                <!--<Setter Property="BorderBrush" Value="{x:Null}"/>-->
                <!-- TODO Template 

                But how does this work? :/
            -->
            </Style>

            <Style TargetType="RibbonGroup">
                <Setter Property="Background" Value="Transparent"/>
                <!--<Setter Property="MouseOverBackground" Value="Transparent"/>
                <Setter Property="MouseOverBorderBrush" Value="Transparent"/>-->
            </Style>



            <Style TargetType="RibbonTabHeader">
                <Setter Property="Background" Value="White"/>
                <Setter Property="BorderBrush" Value="Transparent"/>
                <Setter Property="FontSize" Value="13"/>
                <Setter Property="Padding" Value="15,2,15,2"/>
                <Setter Property="BorderThickness" Value="1,1,1,5"/>
                <Setter Property="Margin" Value="1,0,1,0"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="RibbonTabHeader">
                            <ControlTemplate.Resources>
                                <SolidColorBrush x:Key="CheckedBackground" Color="#FFF5F6F7"/>
                                <SolidColorBrush x:Key="CheckedBorderBrush" Color="#FFDBDCDD"/>
                                <!--<SolidColorBrush x:Key="FocusedBackground" Color="#FFFDFDFF"/>
                                <SolidColorBrush x:Key="FocusedBorderBrush" Color="#FFEDEEEE"/>
                                <SolidColorBrush x:Key="MouseOverBackground" Color="#FFFDFDFF"/>
                                <SolidColorBrush x:Key="MouseOverBorderBrush" Color="#FFEDEEEE"/>-->
                            </ControlTemplate.Resources>

                            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True"/>
                            </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsRibbonTabSelected" Value="True">
                            <Setter Property="Background" Value="{DynamicResource CheckedBackground}"/>
                            <!--<Setter Property="BorderBrush" Value="{DynamicResource CheckedBorderBrush}"/>-->
                            <Setter Property="BorderBrush" Value="#FFB9C9DA"/>
                            <Setter Property="Foreground" Value="Blue"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <!--<Setter Property="Background" Value="{DynamicResource CheckedBackground}"/>-->
                            <!--<Setter Property="BorderBrush" Value="{DynamicResource CheckedBorderBrush}"/>-->
                            <!--<Setter Property="BorderBrush" Value="#FFB9C9DA"/>-->
                            <Setter Property="Foreground" Value="Blue"/>
                        </Trigger>
                        <!--<MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsRibbonTabSelected" Value="False"/>
                                <Condition Property="IsMouseOver" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" Value="{DynamicResource MouseOverBackground}"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource MouseOverBorderBrush}"/>
                        </MultiTrigger>-->
                    </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

        </Window.Resources>

        <Grid>

            <Ribbon>
                <RibbonTab Header="INICIO">
                    <RibbonGroup Header="Portapapeles">
                        <RibbonButton Label="Hola" LargeImageSource="Imágenes/Artículo.png" Height="Auto" VerticalAlignment="Top"/>
                    </RibbonGroup>
                    <RibbonGroup Header="Fuente">
                        <RibbonButton Content="Fuente"/>
                    </RibbonGroup>
                </RibbonTab>
                <RibbonTab Header="INSERTAR"/>
                <RibbonTab Header="DISEÑO"/>
                <Ribbon.ApplicationMenu>
                    <RibbonApplicationMenu SmallImageSource="Imágenes/Usuario.png">
                        <RibbonApplicationMenuItem Width="Auto" Header="Iniciar sesión..." ImageSource="Imágenes/Usuario.png"/>
                        <RibbonApplicationMenuItem Width="Auto" Header="Cambiar contraseña..." ImageSource="Imágenes/Usuario.png"/>
                        <RibbonApplicationMenuItem Width="Auto" Header="Cerrar sesión..." ImageSource="Imágenes/Usuario.png"/>
                    </RibbonApplicationMenu>
                </Ribbon.ApplicationMenu>
            </Ribbon>

        </Grid>
    </Window>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM