有什么方法可以隐藏AnchorableContextMenu图标吗?
<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
答案 0 :(得分:0)
没有简单的属性可以设置为隐藏按钮。 Style
也不行,因为AnchorablePaneTitle
的默认控件模板在本地设置样式。
所以唯一的方法是完全覆盖控制模板。
您可以使用AnchorablePaneTitle
中的default 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>