Make TabControl Headers Scrollable in WPF

泄露秘密 提交于 2019-11-30 15:37:25

Changing TabControl.Template to something simple like this seems to work for me

<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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!