如何隐藏可锚定的上下文菜单图标?

How to hide AnchorableContextMenu icon?

有什么方法可以隐藏 Anchorable ContextMenu 图标吗?

<ad:DockingManager x:Name="dockingManager" Loaded="DockingManagerLoaded">
        <ad:DockingManager.Theme>
            <xcad1:AeroTheme/>
        </ad:DockingManager.Theme>
        <ad:DockingManager.AnchorableContextMenu>
            <ContextMenu IsEnabled="False" Visibility="Hidden"/>
        </ad:DockingManager.AnchorableContextMenu>
        <Layout:LayoutRoot>
            <Layout:LayoutPanel Orientation="Horizontal">
                <Layout:LayoutAnchorablePane DockWidth="300">
                    <Layout:LayoutAnchorable

没有简单的属性可以设置隐藏按钮。 Style 方法不会太有效,因为 AnchorablePaneTitle 的默认控件模板在本地设置样式。

所以唯一的办法就是完全覆盖控件模板。

您可以使用AnchorablePaneTitledefault template并根据需要进行更改。

这是一个例子:

<xcad:DockingManager>   
  <xcad:DockingManager.Resources>
    <Style TargetType="xcad:AnchorablePaneTitle">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="xcad:AnchorablePaneTitle">
            <Border
                 Background="{TemplateBinding Background}" 
                 BorderBrush="{TemplateBinding BorderBrush}" 
                 BorderThickness="{TemplateBinding BorderThickness}">
              <Grid>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <xcad:DropDownControlArea
                  DropDownContextMenu="{Binding Model.Root.Manager.AnchorableContextMenu, RelativeSource={RelativeSource TemplatedParent}}"
                  DropDownContextMenuDataContext="{Binding Path=LayoutItem, RelativeSource={RelativeSource TemplatedParent}}">
                  <ContentPresenter Content="{Binding Model, RelativeSource={RelativeSource TemplatedParent}}"
                    ContentTemplate="{Binding Model.Root.Manager.AnchorableTitleTemplate, RelativeSource={RelativeSource TemplatedParent}}"
                    ContentTemplateSelector="{Binding Model.Root.Manager.AnchorableTitleTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" />
                </xcad:DropDownControlArea>

                <Button x:Name="PART_HidePin"
                  Grid.Column="1"
                  Focusable="False"
                  Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                  Command="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}"
                  ToolTip="{x:Static avalonDockProperties:Resources.Anchorable_BtnClose_Hint}">
                  <Border Background="White">
                    <Image Source="/Xceed.Wpf.AvalonDock;component/Themes/Generic/Images/PinClose.png"/>
                  </Border>
                </Button>
              </Grid>
            </Border>
            <ControlTemplate.Triggers>
              <DataTrigger Binding="{Binding Model.CanClose, RelativeSource={RelativeSource Mode=Self}}"
                     Value="True">
                <Setter Property="Command"
                  TargetName="PART_HidePin"
                  Value="{Binding Path=LayoutItem.CloseCommand, RelativeSource={RelativeSource TemplatedParent}}" />
                <Setter Property="ToolTip"
                  TargetName="PART_HidePin"
                  Value="{x:Static avalonDockProperties:Resources.Document_Close}" />

              </DataTrigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </xcad:DockingManager.Resources>
</xcad:DockingManager>