Vertical separator in WPF Ribbon

10,115

Solution 1

This is how I would do it.

<ribbon:RibbonGroup.Resources>
    <!-- Vertical Separator-->
    <Style TargetType="{x:Type ribbon:RibbonSeparator}"
           x:Key="KeyRibbonSeparatorVertical">
        <Setter Property="LayoutTransform">
            <Setter.Value>
                <RotateTransform Angle="90"/>
            </Setter.Value>
        </Setter>
    </Style>
</ribbon:RibbonGroup.Resources>

Solution 2

It looks like this doesn't work in the latest version (3.5.40729.1) anymore. The RibbonSeparator also doesn;t work, but you can use:

<Ribbon:RibbonControlGroup Height="55" Margin="5" Width="1" MinHeight="55" MaxWidth="1"/>

Solution 3

You can wrap what you have in a RibbonGroup, a vertical separator is created to the right of the group.

Vertical Ribbon Separator using RibbonGroup as wrapper

All I did was wrapped the first button in a RibbonGroup.

<ribbon:RibbonTab x:Name="HomeTab" 
                  Header="Home">
    <ribbon:RibbonGroup x:Name="Group1" 
                        Header="Group1">
        <ribbon:RibbonGroup>
            <ribbon:RibbonButton x:Name="Button1"
                             LargeImageSource="Images\LargeIcon.png"
                             Label="Button1" Margin="-5" />
        </ribbon:RibbonGroup>

        <ribbon:RibbonButton x:Name="Button2"
                             SmallImageSource="Images\SmallIcon.png"
                             Label="Button2" />
        <ribbon:RibbonButton x:Name="Button3"
                             SmallImageSource="Images\SmallIcon.png"
                             Label="Button3" />
        <ribbon:RibbonButton x:Name="Button4"
                             SmallImageSource="Images\SmallIcon.png"
                             Label="Button4" />
    </ribbon:RibbonGroup>

</ribbon:RibbonTab>

Solution 4

You can use a RibbonLabel, which can host any control in a RibbonGroup. It comes in very handy!

For a vertical line separator, you can try this:

<ribbon:RibbonLabel>
    <Rectangle Height="56" Margin="2,0" Stroke="Silver"/>
</ribbon:RibbonLabel>

(Of course, you can style it as you see fit for the app..)

Solution 5

Works with me-

                <my:RibbonSeparator Margin="5,0" Width="70" BorderBrush="Navy" BorderThickness="2">
                    <my:RibbonSeparator.RenderTransform>
                        <RotateTransform Angle="90" />
                    </my:RibbonSeparator.RenderTransform>
                </my:RibbonSeparator>
Share:
10,115
Marta
Author by

Marta

Updated on June 20, 2022

Comments

  • Marta
    Marta almost 2 years

    How can I add Vertical separator to WPF Ribbon, to RibbonGroup? I have tried something like that, but i got horizontal separator istead of vertical.

    <r:RibbonGroup>
    <r:RibbonButton Command="{StaticResource SomeButton}" />     
     <r:RibbonSeparator></r:RibbonSeparator> 
     <r:RibbonToggleButton IsChecked="False" Command="{StaticResource AnotherButton}"/></r:RibbonToggleButton>
     </r:RibbonGroup>
    

    So how can I make vertical separator?

  • Marta
    Marta over 12 years
    This solution works in new Ribbon version. Solution with RibbonLabel is not working now cause there is no RibbonLabel in new wpf Ribbon.
  • akovar
    akovar about 9 years
    or if you want to avoid hardcoded color use binding for Background="{Binding Path=BorderBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type my:Ribbon}}}"