Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MahApps.Metro cannot find resources

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.

like image 568
Aleksey Shubin Avatar asked Dec 02 '13 09:12

Aleksey Shubin


1 Answers

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>
like image 117
punker76 Avatar answered Oct 03 '22 01:10

punker76