2017-07-26 105 views
2

所以我要简单MenuItemWPF:如何删除菜单项边框

<ListView.ContextMenu> 
    <ContextMenu Name="cmCopy"> 
     <MenuItem Style="{StaticResource MenuItemDefaultStyle}" Header="Copy" Click="MenuItem_Click"/> 
    </ContextMenu> 
</ListView.ContextMenu> 

而且我Style

<Style x:Key="MenuItemDefaultStyle" TargetType="{x:Type MenuItem}"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type MenuItem}"> 
       <Grid SnapsToDevicePixels="true"> 
        <DockPanel> 
         <ContentPresenter x:Name="Icon" ContentSource="Icon" Margin="4,0,6,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/> 
         <Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="7,0,0,0" Visibility="Collapsed" VerticalAlignment="Center"/> 
         <ContentPresenter x:Name="content" ContentSource="Header" Width="40" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> 
        </DockPanel> 
        <Popup x:Name="PART_Popup" AllowsTransparency="true" Focusable="false" HorizontalOffset="1" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Placement="Bottom" VerticalOffset="-1"> 

         <Border BorderThickness="0" BorderBrush="Transparent" Background="{TemplateBinding Background}"> 
          <ScrollViewer x:Name="SubMenuScrollViewer" CanContentScroll="true" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}"> 
           <Grid RenderOptions.ClearTypeHint="Enabled"> 
            <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="true" Margin="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle"/> 
           </Grid> 
          </ScrollViewer> 
         </Border> 
        </Popup> 
       </Grid> 
       <ControlTemplate.Triggers> 
        <Trigger Property="IsMouseOver" Value="True"> 
         <Setter Property="TextBlock.Foreground" Value="Blue" TargetName="content"/> 
        </Trigger> 
       </ControlTemplate.Triggers> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

,我真的想s到删除我MenuItem围绕此边框。

,虽然我定义是:”

<Border BorderThickness="0" BorderBrush="Transparent" Background="{TemplateBinding Background}"> 

我仍然可以看到黑色Border刷。

更新

enter image description here

+0

'Style'中的'Border'是为不是'MenuItem'的弹出框指定的。 – XAMlMAX

+0

那么我应该改变什么? – user979033

+0

在样式'