Pregunta

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

I created the simplest project I could, but the system buttons (Minimize and Close) are not styled correctly.
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>

I think I followed the QuickStart correctly -- what have I overlooked?
Thanks --

¿Fue útil?

Solución

Try adding

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

instead of the commented line you got

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

Note the change in spelling for the resource file. You need Colors.xaml instead of Colours.xaml and it should work fine.

Without Colors.xaml you should have seen warnings such as:

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

that indicates the Brush required by those control's are missing and they are as we can guess defined in Colors.xaml. So adding that resource should sort your issue out.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top