隐藏上下文菜单边框 [英] Hide contextmenu border

查看:83
本文介绍了隐藏上下文菜单边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何隐藏contextMenu边框?

它似乎是默认样式的一部分。



谢谢,



屏幕截图在这里

https://ibb.co/btNCUp



我尝试过:



Hi,
How to hide contextMenu border ?
It seems it's part of default style.

Thank you,

A screenshot is here
https://ibb.co/btNCUp

What I have tried:

<ToggleButton Name="MyButton">
 <StackPanel Orientation="Vertical">
  <Image Source="{Binding IconPath , Converter={StaticResource EmptyImageConverter}}" Height="60"/>
  <TextBlock TextAlignment="Center" Text="{Binding Name}"/>
 </StackPanel>

 <ToggleButton.ContextMenu>
 <ContextMenu ContextMenuService.Placement="Top" ItemsSource="{Binding SubViews}" BorderThickness="0">

  <ContextMenu.ItemContainerStyle>
   <Style TargetType="{x:Type MenuItem}">
   <Setter Property="Background" Value="{StaticResource TransparentSliderSolidColorBrush}"/>                                                 
   <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type MenuItem}">
     <Border x:Name="Bd" Background="#181818" SnapsToDevicePixels="True">
      <Grid>
       <Grid.ColumnDefinitions>                                                                                      <ColumnDefinition Width="*"/>                                                                      <ColumnDefinition Width="Auto"/>
                                                                            </Grid.ColumnDefinitions>
<Image Source="{Binding IconPath , Converter={StaticResource EmptyImageConverter}}" Margin="0,0,0,10"/>
                                                                        <TextBlock Grid.Column="1" FontSize="12" Foreground="White" Text="{Binding Name , Mode=OneWay}"  HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,7"/>
 </Grid>
                                                                   
 </Border>
                                                                <ControlTemplate.Triggers>
 <Trigger Property="IsHighlighted" Value="True">
 <Setter TargetName="Bd" Property="Background" Value="{StaticResource ControlBlack500SolidColorBrush}" />
 </Trigger>
                                                                </ControlTemplate.Triggers>
 </ControlTemplate>
 </Setter.Value>
 </Setter>
 </Style>
 </ContextMenu.ItemContainerStyle>
 </ContextMenu>
 </ToggleButton.ContextMenu>
                                    
 </ToggleButton>

推荐答案

请看以下内容:ContextMenu样式和模板| Microsoft Docs [ ^ ]
Look at the following: ContextMenu Styles and Templates | Microsoft Docs[^]


这篇关于隐藏上下文菜单边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆