首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MahApps.Metro找不到资源

MahApps.Metro找不到资源
EN

Stack Overflow用户
提问于 2013-12-02 09:33:52
回答 1查看 7.1K关注 0票数 9

我正在尝试创建新的WPF应用程序设计MahApps.Metro。我完全按照快速启动指南(http://mahapps.com/MahApps.Metro/guides/quick-start.html)中描述的那样做:

  • 将MahApps.Metro包从Nuget添加到项目中。
  • 添加xmlns命名空间并将窗口替换为MetroWindow。

此时,我可以运行应用程序,但是窗口是透明的。标题栏文本和按钮是可见的(并且按钮没有样式),但是背景是透明的。

  • 为窗口添加合并字典代码。

在此之后,我在启动时收到一个异常:

代码语言:javascript
复制
System.IOException
{"Cannot locate resource 'styles/colours.xaml'."}

由于某种原因,它似乎无法在程序集中找到资源。但我不明白为什么。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-04 14:06:28

来自维基

‘颜色’->‘颜色’ 是的,我们把所有的Colours都换成了Colors!颜色的命名不一致,所以我们决定更改命名。此外,资源字典从Colours.xamlColors.xaml

0.11.0发行说明

快怎么做

应用程序

代码语言:javascript
复制
<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

代码语言:javascript
复制
<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>
票数 14
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20324912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档