wpf MahApps.Metro:禁用窗口动画

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16313161/
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 08:42:54  来源:igfitidea点击:

MahApps.Metro: Disabling windows animation

wpfmahapps.metro

提问by Alex Klaus

I'm using MahApps.MetroUI for my WPF application. It's a good one and satisfies my needs, but I'd be more happy if somebody told me how to disable windows animation when they pop up.

我正在为我的 WPF 应用程序使用MahApps.MetroUI。这是一个很好的,满足我的需求,但如果有人告诉我如何在弹出时禁用 windows 动画,我会更高兴。

When I call the Show() method, the new window pops up and I see an annoying animation (the content slides from right to left). The effect is similar to another one shown on the picture below (but it shows tabs and content goes left-to-right):

当我调用 Show() 方法时,新窗口弹出,我看到一个烦人的动画(内容从右向左滑动)。效果类似于下图所示的另一个效果(但它显示选项卡和内容从左到右):

Annoying content animation on popup

弹出窗口中烦人的内容动画

Sample of a dummy form please see below:

虚拟表格样本请参见以下内容:

<controls:MetroWindow x:Class="TestProj.Views.TestView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         mc:Ignorable="d" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
         xmlns:vm="clr-namespace:TestProj.ViewsModels"
         Height="230" Width="550">
<Window.Resources>
    <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.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
    <Grid>
    </Grid>
</controls:MetroWindow>

回答by Joee

Set WindowTransitionsEnabled="False"in xaml of the window.

WindowTransitionsEnabled="False"在窗口的 xaml 中设置。

回答by Brendan Forster

As discussed on the equivalent GitHUb issue, the MetroWindowcontrol template by default will use a MetroContentControl(which has this animation).

正如在等效的 GitHUb 问题上所讨论的MetroWindow,默认情况下,控件模板将使用 a MetroContentControl(具有此动画)。

You need to edit the template to change it back to a ContentControl.

您需要编辑模板以将其改回ContentControl.

Sample code here

示例代码在这里