Search code examples
wpfribbon

How to remove vertical separating line between buttons in RibbonControlGroup?


I have added RibbonControlGroup as a container for my RibbonButton's:

                <RibbonGroup>
                  <RibbonControlGroup>
                    <RibbonButton/>
                    <RibbonButton/>
                  </RibbonControlGroup>
                </RibbonGroup>

But how to remove a vertical separating line between buttons in System.Windows.Controls.Ribbon.RibbonControlGroup?

I have <Setter Property="BorderBrush" Value="Transparent"/> in style definition for RibbonGroup, RibbonControlGroup and RibbonButton but the same problem remains...

Screenshot:

enter image description here


Solution

  • The ControlTemplate for various RibbonControls has triggers that add a right hand side border when they are in a control group (i.e. the IsInControlGroup Property is True):

    <!-- IsInControlGroup -->
    <Trigger Property="IsInControlGroup" Value="True">
        <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Ribbon.BorderBrush}" />
        <Setter TargetName="OuterBorder" Property="BorderThickness" Value="0,0,1,0" /> 
        <Setter TargetName="OuterBorder" Property="CornerRadius" Value="0" />
        <Setter TargetName="InnerBorder" Property="CornerRadius" Value="0" />
    </Trigger>
    

    I edited the line :

    <Setter TargetName="OuterBorder" Property="BorderThickness" Value="0,0,1,0" /> 
    

    To :

    <Setter TargetName="OuterBorder" Property="BorderThickness" Value="0,0,0,0" /> 
    

    Alternatively you could just remove the whole trigger.

    NB: Mine was in the Generic.xaml in the Themes folder for the ControlsLibrary project, which had the folowing at the top

    <!--=================================================================
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    This file was generated from individual xaml files found
       in wcp\themes\xaml\, please do not edit it directly.
    
    To generate this file, bcz in Wcp\Themes\Generator and copy 
       the generated theme files from the output directory to
       the corresponding themes\ folder.
    
    To automatically copy the files, set the environment variable
       set THEMEXAML_AUTOUPDATE=1
    
    ==================================================================-->
    

    So you may want to make a copy or regenerate.