MahApps.Metro无法找到资源

  发布于 2023-02-13 14:32

我正在尝试使用MahApps.Metro创建新的WPF应用程序.我完全按照快速入门指南(http://mahapps.com/MahApps.Metro/guides/quick-start.html)中的描述进行操作:

将Nuget的MahApps.Metro包添加到项目中.

添加xmlns命名空间并用MetroWindow替换Window.

此时我可以运行应用程序,但窗口是透明的.标题栏文本和按钮是可见的(按钮未设置样式),但背景是透明的.

为Window添加合并的词典代码.

之后我在启动时收到一个例外:

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

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

1 个回答
  • 来自维基

    '颜色' - >'颜色'

    是的,我们改变了所有ColoursColors!颜色的命名不一致,所以我们决定更改命名.另外,资源字典从去Colours.xamlColors.xaml.

    发行说明为0.11.0

    快速如何

    应用

    <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>
    

    主窗口

    <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"
                          
                          >
      <Grid>
        <!-- now your content -->
    
      </Grid>
    </controls:MetroWindow>
    

    2023-02-13 14:35 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有