【问题标题】:MahApps.Metro: Disabling windows animationMahApps.Metro:禁用 Windows 动画
【发布时间】:2019-03-04 17:11:26
【问题描述】:

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

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

虚拟表格的示例请参见下文:

<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>

【问题讨论】:

    标签: wpf mahapps.metro


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

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

      示例代码here

      【讨论】:

      • 两周前我在上面的链接上报告说你的解决方案解决了这个问题,但是新窗口失去了窗口标题的背景颜色(现在一切都是白色的)。我提供了一个简单的例子来演示这个问题,但没有人回答。您能否至少确认您能够重现我的问题?
      • 原来白色标题背景是上次稳定版本的错误。它在最新的测试版中运行良好。
      猜你喜欢
      • 2011-03-17
      • 2011-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-05
      相关资源
      最近更新 更多