c# - 如何将 AvalonDock Anchorable Pane 选项卡移动到顶部而不是底部?

标签 c# tabs wpftoolkit avalondock

我在一个项目中使用 AvalonDock 并想使用可锚定 Pane ,但我希望它不会出现在底部,而是像在文档 Pane 中那样出现在顶部。对于我的项目,Document Pane 不是合适的控件,因此我需要找到一种方法使 Anchorable Pane 以相同的方式出现。

enter image description here

最佳答案

根据 Issue Ticket found on CodePlex有一个错误阻止将 TabStripPlacement 更改为顶部。实现这一目标的方法是用这样的样式替换现有样式:

<Style x:Key="MyCustomAnchorablePaneControlStyle" TargetType="{x:Type xcad:LayoutAnchorablePaneControl}">

    <Setter Property="TabStripPlacement" Value="Top"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type xcad:LayoutAnchorablePaneControl}">
                <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"/>

                    <xcad:AnchorablePaneTabPanel x:Name="HeaderPanel" Margin="2,0,2,2" IsItemsHost="true" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>

                    <Border x:Name="ContentPanel" 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>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>

    <Setter Property="ItemContainerStyle">
        <Setter.Value>
            <Style TargetType="{x:Type TabItem}">
                <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
                <Setter Property="ToolTip" Value="{Binding ToolTip}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=Items.Count}" Value="1">
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Setter.Value>
    </Setter>

    <Setter Property="ItemTemplate">
        <Setter.Value>
            <DataTemplate>
                <xcad:LayoutAnchorableTabItem Model="{Binding}"/>
            </DataTemplate>
        </Setter.Value>
    </Setter>

    <Setter Property="ContentTemplate">
        <Setter.Value>
            <DataTemplate>
                <xcad:LayoutAnchorableControl Model="{Binding}"/>
            </DataTemplate>
        </Setter.Value>
    </Setter>

</Style>

关于c# - 如何将 AvalonDock Anchorable Pane 选项卡移动到顶部而不是底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29434424/

相关文章:

c# - Asp.net 成员(member)资格使用什么哈希算法?

c# - 为什么会有两种SortedList?

android - 使用 android :configChanges ="orientation|keyboardHidden" in Grid View but working for other Tab 时选项卡小部件问题

c# - WPF TabControl with Materials Design(没有 Dragablz)

WPF 数据网格 : Get column binding property for filtering

c# - 绑定(bind)数据网格列可见性 MVVM

c# - `Select` 元素的顺序是否不同?

c# - 未知数量类型参数的类设计

javascript - Angular-ui-bootstrap -- 无法禁用 ng-repeat 内的选项卡

c# - 扩展 WPF 工具包 - 如何添加对项目的引用?