9

I am trying to create new WPF application usign MahApps.Metro. I do exactly as described in quick start guide (http://mahapps.com/MahApps.Metro/guides/quick-start.html):

  • Add MahApps.Metro package from Nuget to the project.
  • Add xmlns namespace and replaced Window with MetroWindow.

At this point I can run the application, but the window is transparent. Title bar text and buttons are visible (and buttons are not styled), but the background is transparent.

  • Add merged dictionaries code for the Window.

After that I receive an exception on startup:

System.IOException
{"Cannot locate resource 'styles/colours.xaml'."}

Seems as for some reason it cannot find resources in the assembly. But I don't understand why.

Aleksey Shubin
  • 1,960
  • 2
  • 20
  • 39
  • That's a bold but almost certainly incorrect claim in your title. – Sheridan Dec 02 '13 at 09:56
  • @Sheridan, I meant "does not work _for me_". :) Changed the title... – Aleksey Shubin Dec 02 '13 at 10:00
  • You need to put the `Colours.xaml` file into a folder named `Styles` in your root directory. – Sheridan Dec 02 '13 at 10:10
  • @Sheridan where should I take Colours.xaml? Nuget only added Mahapps.Metro dll to project, no .xaml files. – Aleksey Shubin Dec 02 '13 at 10:46
  • Maybe you should contact the author of that example to request that along with the other XAML files? – Sheridan Dec 02 '13 at 10:52
  • I believe the problem is somewhere else. MahApps has 50k+ downloads in Nuget, and if everyone would be required to contact the author, there will be a lot of references to this problem in internet. But I cannot found anything similar... – Aleksey Shubin Dec 02 '13 at 11:19
  • I have been using MahApps lately, and it works great. how and where you add the merged dictionaries? – har07 Dec 02 '13 at 11:21
  • After looking at this again, it *does* seem that those `Style` files are indeed supposed to be included in the dll. While I cannot tell you why you didn't get these XAML files in your download, all I can do is to suggest that you try to download all the files again. Your linked page shows two ways of downloading them, so I'd try both if I were you. – Sheridan Dec 02 '13 at 11:29
  • @har07 I tried to add it both to and . – Aleksey Shubin Dec 02 '13 at 12:09
  • 2
    Colours now Colors -> https://github.com/MahApps/MahApps.Metro/wiki/Breaking-Changes-or-WTF-is-happening-with-the-ALPHA-version#colours---colors – punker76 Dec 02 '13 at 13:21
  • @punker76 thank you! Changed Colours to Colors, and it works now. Seems as they need to update their quick start guide... – Aleksey Shubin Dec 04 '13 at 11:32
  • @punker76 please add it as an answer, and I will accept it. – Aleksey Shubin Dec 04 '13 at 11:33

1 Answers1

14

from the wiki

'Colours' -> 'Colors'

Yes, we changed all Colours to Colors ! The naming of the colors were inconsistent so we decided to change the naming. Also the resource dictionary goes from Colours.xaml to Colors.xaml .

release notes for 0.11.0

Quick How To

Application

<Application x:Class="WpfApplication.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
  <Application.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Application.Resources>
</Application>

MainWindow

<controls:MetroWindow x:Class="WpfApplication.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                      Title="MainWindow"
                      Height="600"
                      Width="800">
  <Grid>
    <!-- now your content -->

  </Grid>
</controls:MetroWindow>
punker76
  • 14,326
  • 5
  • 58
  • 96