【问题标题】:WPF/XAML compiles but errors show in XAMLWPF/XAML 编译但 XAML 中显示错误
【发布时间】:2017-06-07 15:41:59
【问题描述】:

与一位同事一起,我们尝试制作 WPF 应用程序的 POC。我们创建了一个新项目,其中包含一个页面和一个 resx 文件来测试国际化(我们是法国人)。该应用程序运行良好,编译时没有错误,resx 文件提供了良好的数据。 但是在 XAML 文件中,我们有很多错误。

这是 XAML 标头:

<Window x:Class="MAPPrintProcessEditor.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:res="clr-namespace:MAPPrintProcessEditor.Properties"
        mc:Ignorable="d"
        Title="MAP Print Process Editor"
        WindowStartupLocation="CenterScreen"
        Height="{Binding SystemParameters.PrimaryScreenHeight}" Width="{Binding SystemParameters.PrimaryScreenWidth}">

这里是错误标记的一行:

<MenuItem Header="{x:Static res:Resources.MenuItemHeaderClose}">
    <MenuItem.Icon>
        <Image Source="pack://application:,,,/Resources/Close-16.png"/>
    </MenuItem.Icon>
</MenuItem>

Visual Studio 仅在这部分下划线:

Header="{x:Static

最后,这里是错误信息:

命名空间“clr-namespace:PrintProcessEditor.Properties”中不存在名称“Resources”

这段代码有什么问题?

我们使用 VS2017 和 .Net 4.6.1。

【问题讨论】:

  • 如果解决方案构建正常,但在 XAML 设计器中出现虚假错误,请清理解决方案,关闭并重新打开它,然后执行干净构建。 XAML 设计器有时有点滑稽。
  • 我已经试过了;)
  • 这样的话,只要还能构建,就忽略吧。
  • 好的,但是在这种情况下编译之前,我们无法看到我们在 XAML 中做了什么:/
  • .net/visual studio 有哪些版本?

标签: c# wpf xaml resources


【解决方案1】:

如果您可以正确构建,而不仅仅是忽略该消息并使用 BLEND 来设计您的应用程序。

【讨论】:

  • 问题与 Blend 相同;)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-30
相关资源
最近更新 更多