将ControlTemplate添加到AnimatedTabControl而不覆盖动画行为

时间:2015-05-29 20:35:13

标签: wpf tabcontrol controltemplate mahapps.metro

我正在使用MahApps AnimatedTabControl ,我需要创建一个 ControlTemplate 来为标题标签添加ScrollViewer。这是我的模板:

     <TabControl.Template>
            <ControlTemplate TargetType="{x:Type TabControl}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <ScrollViewer x:Name="_MainTabControlScrollViewer" HorizontalScrollBarVisibility="Hidden" 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>

然而,这会杀死动画。有没有办法继承默认的AnimatedTabControl行为?

1 个答案:

答案 0 :(得分:0)

改为覆盖<Controls:MetroAnimatedSingleRowTabControl x:Name="AnimatedTabControl"> <TabItem Header="tab test"></TabItem> </Controls:MetroAnimatedSingleRowTabControl> ,只需使用xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"

{{1}}

{{1}}

希望有所帮助。