Search code examples
wpfribbon

How do I remove the Mouse Over Effect on WPF Ribbon Group?


I'm working on this Ribbon Control in WPF: System.Windows.Controls.Ribbon.Ribbon

I've made the background orange and I've changed the style slightly. It looks like this:

enter image description here

When I move the cursor over a group it looks like this:

enter image description here

I want to remove the white mouse over / hover effect, but I don't know which Style or Template I should look at. I've tried all these:

  • Ribbon
  • RibbonTab
  • RibbonTabHeader
  • RibbonButton
  • RibbonGroup

Is it possible? How do I do it?


Solution

  • So it is inside the style of the RibbonGroup:

        <!--Ribbon Group - Style-->
        <Style TargetType="RibbonGroup">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate x:Name="ribbonGroupControlTemplate" TargetType="RibbonGroup" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
                        <Border Background="{TemplateBinding Panel.Background}" Name="GroupBorder" Margin="1,2,0,0">
                            <Grid Name="MainGrid">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" MinHeight="16" />
                                </Grid.RowDefinitions>
                                <Border BorderThickness="1,1,1,1" CornerRadius="2,2,2,2" BorderBrush="{TemplateBinding RibbonControlService.MouseOverBorderBrush}" Background="{TemplateBinding RibbonControlService.MouseOverBackground}" Name="PART_HotBackground" Opacity="0" SnapsToDevicePixels="True" Grid.RowSpan="3" />
                                <Border Background="{TemplateBinding Border.BorderBrush}" Name="SeparatorBorder" Width="1" Height="75" VerticalAlignment="Center" SnapsToDevicePixels="True" Grid.Column="1" Grid.RowSpan="3" />
                                <Border Padding="3,0,3,0" Margin="2,1,2,0">
                                    <Grid>
                                        <ItemsPresenter Name="ItemsPresenter" />
                                        <ContentControl Name="PART_TemplateContentControl" Visibility="Collapsed" Focusable="False" />
                                    </Grid>
                                      ...
    

    The culprit is this Border:

    <Border BorderThickness="1,1,1,1" CornerRadius="2,2,2,2" BorderBrush="{TemplateBinding RibbonControlService.MouseOverBorderBrush}" Background="{TemplateBinding RibbonControlService.MouseOverBackground}" Name="PART_HotBackground" Opacity="0" SnapsToDevicePixels="True" Grid.RowSpan="3" />
    

    When I comment out or remove that border and the triggers that go with it; it solves my problem.