如标题中所述,我想将 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>
关于c# - 在 WPF 中使 TabControl header 可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26764401/