LayoutDocument 隐藏 DockingManager.DocumentPaneControlStyle 中的标题选项卡 [英] LayoutDocument hide header tabs in DockingManager.DocumentPaneControlStyle
问题描述
我正在使用 Avalondock 2 并且需要隐藏 LayoutDocument
的 TabItem.我知道 Avalondock 1.3 中有一个功能,但在 2.0 中似乎消失了.
I'm using Avalondock 2 and need to hide the TabItem of a LayoutDocument
. I know that there was a function back in Avalondock 1.3 which seems to be gone in 2.0.
我尝试更改 LayoutDocumentPaneControl
的模板,想知道是否可以在不完全重新设计模板的情况下更改单个属性.这就是我想要实现的目标.
I've tried to change the template of the LayoutDocumentPaneControl
and want to know if it's possible to change a single Property without a complete redesign of the template. Here's what I i want to achive.
<xcad:DockingManager.DocumentPaneControlStyle>
<Style TargetType="{x:Type xcad:LayoutDocumentPaneControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type xcad:LayoutDocumentPaneControl}">
<xcad:DocumentPaneTabPanel x:Name="HeaderPanel" IsItemsHost="true" Margin="2,2,2,0" KeyboardNavigation.TabIndex="1" Visibility="Collapsed"/>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</xcad:DockingManager.DocumentPaneControlStyle>
那部分按照我的意愿隐藏了标题,当然还有其他所有内容.
That part hides the Header as I want, but of course everything else too.
那么有没有办法用 BasedOn
或其他东西来隐藏 DocumentPaneTabPanel
?
So is there a way to hide the DocumentPaneTabPanel
with a BasedOn
or something?
TL;博士
有没有办法在 Avalondock 2 中隐藏 DocumentPaneTabPanel
?
Is there a way to hide the DocumentPaneTabPanel
in Avalondock 2?
推荐答案
不幸的是,别无他法.我使用了此处找到的 AvalonDock 2.0:https://avalondock.codeplex.com/
There is no other way unfortunately. I used the AvalonDock 2.0 found here: https://avalondock.codeplex.com/
似乎没有公开任何属性来控制 ControlTemplate
中 DocumentPaneTabPanel
的 Visibility
.如果您检查用于 LayoutDocumentPaneControl
的默认 Style
here 你可以看到没有 TemplateBinding
或任何 DataTrigger
影响 DocumentPaneTabPanel
名为 HeaderPanel
,所以我看不到一种在不修改 ControlTemplate.
There doesn't seem to be any property exposed to control the Visibility
of the DocumentPaneTabPanel
in the ControlTemplate
.
If you check the default Style
used for the LayoutDocumentPaneControl
here you can see that there is no TemplateBinding
or any DataTrigger
affecting the DocumentPaneTabPanel
named HeaderPanel
so I don't see a way of changing it without modifying the ControlTemplate.
您应该创建一个 DockingManagerStyles.xaml
ResourceDictionary
并将其放在那里:
You should create a DockingManagerStyles.xaml
ResourceDictionary
and put this in there:
<xcad:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<xcad:ActivateCommandLayoutItemFromLayoutModelConverter x:Key="ActivateCommandLayoutItemFromLayoutModelConverter"/>
<Style x:Key="TablessDocumentPaneControlStyle" TargetType="{x:Type xcad:LayoutDocumentPaneControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type xcad:LayoutDocumentPaneControl}">
<Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--Following border is required to catch mouse events-->
<Border Background="Transparent" Grid.RowSpan="2"/>
<Grid Panel.ZIndex="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<xcad:DocumentPaneTabPanel x:Name="HeaderPanel" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Visibility="Collapsed"/>
<xcad:DropDownButton x:Name="MenuDropDownButton"
Style="{StaticResource {x:Static ToolBar.ToggleButtonStyleKey}}"
Focusable="False" Grid.Column="1">
<xcad:DropDownButton.DropDownContextMenu>
<xcad:ContextMenuEx
ItemsSource="{Binding Model.ChildrenSorted, RelativeSource={RelativeSource TemplatedParent}}">
<xcad:ContextMenuEx.ItemContainerStyle>
<Style TargetType="{x:Type xcad:MenuItemEx}" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="HeaderTemplate" Value="{Binding Path=Root.Manager.DocumentPaneMenuItemHeaderTemplate}"/>
<Setter Property="HeaderTemplateSelector" Value="{Binding Path=Root.Manager.DocumentPaneMenuItemHeaderTemplateSelector}"/>
<Setter Property="IconTemplate" Value="{Binding Path=Root.Manager.IconContentTemplate}"/>
<Setter Property="IconTemplateSelector" Value="{Binding Path=Root.Manager.IconContentTemplateSelector}"/>
<Setter Property="Command" Value="{Binding Path=., Converter={StaticResource ActivateCommandLayoutItemFromLayoutModelConverter}}"/>
</Style>
</xcad:ContextMenuEx.ItemContainerStyle>
</xcad:ContextMenuEx>
</xcad:DropDownButton.DropDownContextMenu>
<Image Source="/Xceed.Wpf.AvalonDock;component/Themes/Generic/Images/PinDocMenu.png"/>
</xcad:DropDownButton>
</Grid>
<Border x:Name="ContentPanel"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Grid.Column="0"
KeyboardNavigation.DirectionalNavigation="Contained"
Grid.Row="1"
KeyboardNavigation.TabIndex="2"
KeyboardNavigation.TabNavigation="Cycle">
<ContentPresenter x:Name="PART_SelectedContentHost"
ContentSource="SelectedContent"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Model.ChildrenCount}" Value="0">
<Setter Property="Visibility" Value="Collapsed" TargetName="MenuDropDownButton" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource BoolToVisibilityConverter}}"/>
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
<Setter Property="ToolTip" Value="{Binding ToolTip}"/>
</Style>
</Setter.Value>
</Setter>
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<xcad:LayoutDocumentTabItem Model="{Binding}"/>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<xcad:LayoutDocumentControl Model="{Binding}"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
然后将其包含在 App.xaml
的 MergedDictionaries
部分中,以在应用程序中全局更改选项卡.
Then include it in the MergedDictionaries
section of your App.xaml
to change the tabs globally in your application.
您应该可以像这样使用它:
You should be able to use it like:
<xcad:DockingManager DocumentPaneControlStyle="{StaticResource TablessDocumentPaneControlStyle}">
<!-- Layout here -->
</xcad:DockingManager>
更新
在 NuGet 上的最新版本中有一个LayoutDocumentPane
上的 ShowHeader
属性.所以在那个版本中你可以这样做:
In the latest version on NuGet there is a ShowHeader
property on LayoutDocumentPane
. So in that version you can just do:
<xcad:DockingManager>
<xcad:LayoutRoot>
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutPanel Orientation="Vertical">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutDocumentPaneGroup x:Name="leftDocumentGroup">
<xcad:LayoutDocumentPane ShowHeader="False">
<xcad:LayoutDocument Title="Left Doc"></xcad:LayoutDocument>
</xcad:LayoutDocumentPane>
</xcad:LayoutDocumentPaneGroup>
<xcad:LayoutDocumentPaneGroup x:Name="rightDocumentGroup">
<xcad:LayoutDocumentPane>
<xcad:LayoutDocument Title="Right Doc"></xcad:LayoutDocument>
</xcad:LayoutDocumentPane>
</xcad:LayoutDocumentPaneGroup>
</xcad:LayoutPanel>
</xcad:LayoutPanel>
</xcad:LayoutPanel>
</xcad:LayoutRoot>
</xcad:DockingManager>
这篇关于LayoutDocument 隐藏 DockingManager.DocumentPaneControlStyle 中的标题选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!