如何删除WPF功能区组上的鼠标悬停效果?

时间:2018-08-21 09:33:55

标签: wpf ribbon

我正在使用WPF中的功能区控件:System.Windows.Controls.Ribbon.Ribbon

我将背景设为橙色,并且略微更改了样式。看起来像这样:

enter image description here

当我将光标移到某个组上时,它看起来像这样:

enter image description here

我想去除白色鼠标悬停/悬停效果,但是我不知道应该看哪种样式或模板。我已经尝试了所有这些:

  • 丝带
  • RibbonTab
  • RibbonTabHeader
  • RibbonButton
  • RibbonGroup

有可能吗?我该怎么办?

1 个答案:

答案 0 :(得分:0)

因此它位于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>
                                  ...

罪魁祸首是边界:

<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" />

当我注释掉或删除该边框及其附带的触发器时;它解决了我的问题。