[英]Make TabControl Headers Scrollable in WPF
As Mentioned in Title, I want to change the header of my TabControl to be scrollable. 正如标题中提到的,我想将TabControl的标题更改为可滚动。
The reason: I have too many tabItems, and the wrapping is not the best solution in my case. 原因是:我有太多的tabItems,在我的情况下,包装不是最好的解决方案。 so I want to change it from :
所以我想改变它:
To something like that (Scroll bar indicated by the arrow) : 对于类似的东西(箭头指示的滚动条):
Can anyone help me and show how to do that ? 谁能帮助我并展示如何做到这一点? (I'm using wpf)
(我正在使用wpf)
Changing TabControl.Template
to something simple like this seems to work for me 将
TabControl.Template
更改为这样的简单似乎对我TabControl.Template
<TabControl ...>
<TabControl.Template>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">
<TabPanel x:Name="HeaderPanel" IsItemsHost="True" Margin="0,4,0,0"/>
</ScrollViewer>
<ContentPresenter x:Name="PART_SelectedContentHost" Margin="4" ContentSource="SelectedContent" Grid.Row="1"/>
</Grid>
</ControlTemplate>
</TabControl.Template>
</TabControl>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.