LayoutDocument隐藏DockingManager.DocumentPaneControlStyle中的标题选项卡

时间:2016-02-15 09:20:31

标签: wpf xaml avalondock

我使用Avalondock 2并需要隐藏LayoutDocument的TabItem。我知道Avalondock 1.3中有一个函数,它似乎在2.0中消失了。

我尝试更改LayoutDocumentPaneControl的模板,并想知道在没有完全重新设计模板的情况下是否可以更改单个属性。这就是我想要实现的目标。

<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>

那部分按照我的意愿隐藏了标题,当然也包括其他一切。

那么有没有办法隐藏DocumentPaneTabPanel BasedOn或其他什么?

TL; DR

有没有办法隐藏Avalondock 2中的DocumentPaneTabPanel

1 个答案:

答案 0 :(得分:2)

遗憾的是没有其他方法。我使用了这里找到的AvalonDock 2.0:https://avalondock.codeplex.com/

似乎没有任何属性可以控制UIDatePickerVisibility的{​​{1}}。 如果您选中DocumentPaneTabPanel here使用的默认ControlTemplate,则可以看到没有Style或任何LayoutDocumentPaneControl影响TemplateBinding命名DataTrigger所以在没有修改DocumentPaneTabPanel

的情况下,我没有看到改变它的方法

您应该创建一个HeaderPanel ControlTemplate.并将其放在那里:

DockingManagerStyles.xaml

然后将其包含在ResourceDictionary的{​​{1}}部分中,以便在应用中全局更改标签。

您应该可以像以下一样使用它:

<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>

<强>更新

latest version on NuGet中,MergedDictionaries上有App.xaml个属性。所以在那个版本中你可以做到:

<xcad:DockingManager DocumentPaneControlStyle="{StaticResource TablessDocumentPaneControlStyle}">
    <!-- Layout here -->
</xcad:DockingManager>