wpf 如何在 MahApps.Metro 中添加 AnimatedTabControl?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13148987/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 06:00:49  来源:igfitidea点击:

How to add AnimatedTabControl in MahApps.Metro?

c#wpfwindows-8mahapps.metro

提问by Nickon

I have started learning MahApps.Metro. I read the documentation and got a problem. How to add AnimatedTabControl?

我已经开始学习了MahApps.Metro。我阅读了文档并遇到了问题。如何添加AnimatedTabControl

I've included ResourceDictionaries:

我已经包括ResourceDictionaries

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Purple.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

After that I started to develop the window:

之后我开始开发窗口:

<Controls:MetroWindow x:Class="MyProject.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:behaviours="clr-namespace:MahApps.Metro.Behaviours;assembly=MahApps.Metro"
        Title="MyProject" ShowIconOnTitleBar="True" SaveWindowPosition="True" Height="350" Width="525">
    <Window.Resources>
        <ResourceDictionary Source="Styles\MetroStyles.xaml" />
    </Window.Resources>

    <Controls:MetroWindow.WindowCommands>
        <Controls:WindowCommands>
            <Button Content="about" />
            <Button Content="settings" />
        </Controls:WindowCommands>
    </Controls:MetroWindow.WindowCommands>

    <Grid>
        <Controls:TransitioningContentControl x:Name="Transitioning" Transition="RightReplaceTransition">

        </Controls:TransitioningContentControl>
    </Grid>
</Controls:MetroWindow>

Metrowindow works fine but I have no idea how to add AnimatedTabControl... It's not included in Controls:namespace.

Metro窗口工作正常,但我不知道如何添加AnimatedTabControl......它不包含在Controls:命名空间中。

I want to do something like that:
Tabs

我想做这样的事情:
标签

回答by Tolga E

You add the

你添加

<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />

to the

 <ResourceDictionary.MergedDictionaries>

element at the top of the .xaml then your TabControl will be animated (you still use the TabControltag but it will use the Controls.AnimatedTabControl style..

.xaml 顶部的元素然后你的 TabControl 将被动画化(你仍然使用TabControl标签,但它将使用 Controls.AnimatedTabControl 样式..

Here's the example of the whole ResourceDictionary tag

这是整个 ResourceDictionary 标记的示例

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>