How to remove the "button" effect for a menu item (WPF)

When the mouse is above the menu item (first level), it displays the effect of a 3D button. How can this be removed?

Thank.


EDIT

Tried to

<Style TargetType="MenuItem">
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="BorderBrush" Value="Transparent">
            <Setter Property="BorderThickness" Value="0">
        </Trigger>
    </Style.Triggers>
</Style>

no effect.

XAML menu:

<Window x:Class="UCWPF.Window3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:conv="clr-namespace:UCWPF.Converters"
    Title="Window3" Height="600" Width="600"
    Background="{StaticResource WindowBackgroundBrush}"
    >

<StackPanel Style="{StaticResource WindowContainerStyle}">
    <Menu>
        <MenuItem Header="New" Icon="{StaticResource ImageNew}" />
        <MenuItem Header="Open" Icon="{StaticResource ImageOpen}" />
        <MenuItem Header="Save" Icon="{StaticResource ImageSave}" />
        <MenuItem Header="Export" Icon="{StaticResource ImageExport}" />
    </Menu>
...

And here is a screenshot: bordereffect http://img408.imageshack.us/img408/6517/menuborder.png


EDIT 2 :

With great power comes great ... complexity: (.

It seems that the entire menu template needs to be redefined to achieve my goal. The 3D effect is set by the MenuItem child border (identified with Snoop), which, when hovering, sets its BorderStyle to be enhanced. I do not know if this border style can be affected inside the element <Style TargetType="MenuItem">, any feedback would be greatly appreciated.

+3
2
<Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Style.Triggers>
  <Trigger Property="Role" Value="TopLevelHeader">
    <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.TopLevelHeaderTemplateKey}}"/>
    <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
  </Trigger>
</Style.Triggers>

  <ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
<Border Name="Border" >
  <Grid>
    <ContentPresenter
      Margin="6,3,6,3"
      ContentSource="Header"
      RecognizesAccessKey="True" />
    <Popup
      Name="Popup"
      Placement="Bottom"
      IsOpen="{TemplateBinding IsSubmenuOpen}"
      AllowsTransparency="True"
      Focusable="False"
      PopupAnimation="Fade">
      <Border
        Name="SubmenuBorder"
        SnapsToDevicePixels="True"
        Background="{DynamicResource NormalBrush}"
        BorderBrush="{StaticResource SolidBorderBrush}"
        BorderThickness="1" >
        <ScrollViewer CanContentScroll="True"
          Style="{StaticResource MenuScrollViewer}">
          <StackPanel
          IsItemsHost="True"
          KeyboardNavigation.DirectionalNavigation="Cycle" />
        </ScrollViewer>
      </Border>
    </Popup>
  </Grid>
</Border>
<ControlTemplate.Triggers>
  <Trigger Property="IsSuspendingPopupAnimation" Value="true">
    <Setter TargetName="Popup" Property="PopupAnimation" Value="None"/>
  </Trigger>
  <Trigger Property="IsHighlighted" Value="true">
    <Setter TargetName="Border" Property="Background" Value="{StaticResource NormalBrush}"/>
    <Setter TargetName="Border" Property="BorderBrush" Value="Transparent"/>
  </Trigger>
  <!--Snippettoplevelheader-->
  <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="True">
    <Setter TargetName="SubmenuBorder" Property="CornerRadius" Value="0,0,4,4"/>
    <Setter TargetName="SubmenuBorder" Property="Padding" Value="0,0,0,3"/>
  </Trigger>
  <!--/Snippettoplevelheader-->
  <Trigger Property="IsEnabled" Value="False">
    <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
  </Trigger>
</ControlTemplate.Triggers>

IsHighlighted , , , ,

. http://msdn.microsoft.com/en-us/library/ms771597%28VS.85%29.aspx

+2
<MenuItem Header="Menu...">
            <MenuItem Header="(none)"/>
            <Separator/>

            <MenuItem>
                <MenuItem.Template>
                    <ControlTemplate>
                        <ItemsControl ItemsSource="{Binding Items}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <MenuItem Header="{Binding .}"/>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </ControlTemplate>
                </MenuItem.Template>
            </MenuItem>
        </MenuItem>
+1

Source: https://habr.com/ru/post/1741225/


All Articles