在设置 AvalonDock 文档选项卡面板的样式和编辑时遇到问题

发布于 2024-12-11 19:49:07 字数 2298 浏览 5 评论 0原文

我正在尝试弄清楚如何使 AvalonDock 的 VS2010 风格的功能更像 VS2010。我遇到的问题是,当选项卡数量超过标题区域所能容纳的数量时,不会向用户表明存在更多选项卡。

我认为选项卡标题只是被剪裁而不可见。我有一个 VS2010 样式的自定义副本,并转到 DocumentPane 样式:

<!--DocumentPane-->
<Style x:Key="{x:Type ad:DocumentPane}" TargetType="{x:Type ad:DocumentPane}"> ...

并发现选项卡标题(我认为)为“ad:DocumentTabPanel”。我将其包装在 ScrollViewer 中:

<ScrollViewer Style="{StaticResource ResourceKey=TabHeaderScrollViewer}"  CanContentScroll="True">

    <ad:DocumentTabPanel 
        x:Name="paneTabsPanel" 
        Panel.ZIndex ="1" 
        IsItemsHost="True" 
        TabItemStyle="{StaticResource CustomDocumentTabItemStyle}"/>
</ScrollViewer>

滚动查看器设置为具有自定义样式:

<Style x:Key="TabHeaderScrollViewer" TargetType="ScrollViewer">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ScrollViewer">
                <Grid Background="{TemplateBinding Background}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <RepeatButton Command="ScrollBar.PageLeftCommand"></RepeatButton>
                    <ScrollContentPresenter Grid.Column="1" 
                                                x:Name="ScrollContentPresenter"
                                                Cursor="{TemplateBinding Cursor}"
                                                Margin="{TemplateBinding Padding}"
                                                ContentTemplate="{TemplateBinding ContentTemplate}"/>

                        <RepeatButton Grid.Column="2" Command="ScrollBar.PageRightCommand"></RepeatButton>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

我遇到的问题是,即使我加载大量选项卡,滚动也不起作用。我不认为这对我的造型有问题。选项卡标题似乎不在 VisualTree 中或具有折叠的可见性。我已经浏览 AvalonDock 源代码有一段时间了,但我看不到标头是如何隐藏的。

我已经不得不对一些 AvalonDock 类进行子类化,因为我需要它们的附加属性。

有人可以解释/帮助我想出滚动选项卡的解决方案吗?

I'm trying to figure out how to make the VS2010 style for AvalonDock to function a little more like VS2010. The problem that I'm running into is that when there are more tabs than can fit in the header area there is no indication to the user that there are more tabs.

I thought that the tab headers were just clipped and not visible. I have a custom copy of the VS2010 style and went to the DocumentPane style:

<!--DocumentPane-->
<Style x:Key="{x:Type ad:DocumentPane}" TargetType="{x:Type ad:DocumentPane}"> ...

And found the tab headers (I think) as a "ad:DocumentTabPanel". I wrapped this in a ScrollViewer:

<ScrollViewer Style="{StaticResource ResourceKey=TabHeaderScrollViewer}"  CanContentScroll="True">

    <ad:DocumentTabPanel 
        x:Name="paneTabsPanel" 
        Panel.ZIndex ="1" 
        IsItemsHost="True" 
        TabItemStyle="{StaticResource CustomDocumentTabItemStyle}"/>
</ScrollViewer>

The scroll viewer is setup to have a custom style on it:

<Style x:Key="TabHeaderScrollViewer" TargetType="ScrollViewer">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ScrollViewer">
                <Grid Background="{TemplateBinding Background}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <RepeatButton Command="ScrollBar.PageLeftCommand"></RepeatButton>
                    <ScrollContentPresenter Grid.Column="1" 
                                                x:Name="ScrollContentPresenter"
                                                Cursor="{TemplateBinding Cursor}"
                                                Margin="{TemplateBinding Padding}"
                                                ContentTemplate="{TemplateBinding ContentTemplate}"/>

                        <RepeatButton Grid.Column="2" Command="ScrollBar.PageRightCommand"></RepeatButton>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

The problem I am having is that even when I load up a ton of tabs the scrolling doesn't work. I don't think this is an issue with my styling. It appears that the tab headers aren't in the VisualTree or have a collapsed visibility. I've been going through the AvalonDock source for a while, but I can't see how the headers are hidden.

I've already had to subclass some of the AvalonDock classes because I needed additional properties on them.

Can someone either explain/help me come up with a solution to scroll the tabs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

可爱暴击 2024-12-18 19:49:07

问题很简单就解决了。我必须设置 Horizo​​ntalScrollBarVisibility="Auto"。我检查了 http://msdn.microsoft.com /en-us/library/system.windows.controls.scrollviewer.horizo​​ntalscrollbarvisibility.aspx 查看此属性的默认值,但是在那里或 ScrollViewer 页面上没有看到。我认为它默认为“隐藏”。

无论如何,一旦设置为“自动”,重复按钮仅在选项卡溢出时显示。

Problem was solved very simply. I had to set the HorizontalScrollBarVisibility="Auto". I checked http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.horizontalscrollbarvisibility.aspx to see what the default value is for this property, but didn't see one there or on the ScrollViewer page. I assume it defaults to "Hidden".

Anyhow, once set to "Auto" the repeat buttons are shown only when the tabs overflow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文