正如标题中提到的,我想将 TabControl 的标题更改为可滚动。
原因:我有太多 tabItems,并且换行对于我来说不是最好的解决方案。所以我想将其更改为:
类似的东西(由箭头指示的滚动条):
谁能帮助我并展示如何做到这一点? (我使用的是wpf)
改变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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)