MahApps Metro标题栏按钮未正确设置样式

时间:2014-04-18 14:33:54

标签: wpf mahapps.metro

Win7,VS2012,MahApps.Metro.0.13.1.0,MVVMLight 4.2.30.0

我创建了最简单的项目,但是系统按钮(最小化和关闭)没有正确设置样式。
enter image description here

MainWindow.xaml:

<controls1:MetroWindow
x:Class="MahMetro.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ignore="http://www.ignore.com"
    xmlns:controls1="http://metro.mahapps.com/winfx/xaml/controls"
    mc:Ignorable="d ignore"
    Height="300" Width="300"
    Title="MVVM Light Application"
    ResizeMode="CanMinimize"   WindowStyle="ToolWindow"
    DataContext="{Binding Main, Source={StaticResource Locator}}">
<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Skins/MainSkin.xaml" />
            <ResourceDictionary Source="Skins/MainSkin.xaml" />
            <!-- <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="/Resources/Icons.xaml" />
            <ResourceDictionary Source="/Resources/IndicatorIcons.xaml"  />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

<Grid x:Name="LayoutRoot">
    <TextBlock FontSize="36"
               FontWeight="Bold"
               Foreground="Purple"
               Text="{Binding WelcomeTitle}"
               VerticalAlignment="Center"
               HorizontalAlignment="Center"
               TextWrapping="Wrap" />

</Grid>

我认为我正确地遵循了QuickStart - 我忽略了什么? 谢谢 -

1 个答案:

答案 0 :(得分:4)

尝试添加

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

而不是你得到的注释行

<!-- <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" /> -->

请注意资源文件的拼写更改。您需要Colors.xaml而不是Colours.xaml,它应该可以正常工作。

如果没有Colors.xaml,您应该看到警告,例如:

System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='SemiTransparentWhiteBrush'

表示缺少这些控件所需的Brush,我们可以在Colors.xaml中定义它们。因此,添加该资源应该可以解决您的问题。