小编Zom*_*bik的帖子

在 wpf 中找不到“资源”文件

我是 WPF 的新手。我需要在资源文件 resx 上添加引用并从中获取字符串。

<Window x:Class="SelectObjectsWindow.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:res="clr-namespace:SelectObjectsWindow.Properties"

    Title="{x:Static res:Resources.Res1}" Height="350" Width="525">
<Grid>
    ....
</Grid>
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:名称“Resources”在命名空间“clr-namespace:SelectObjectsWindow.Properties”中不存在。我正在搜索有关此的信息并找到一些建议:设置 resx 文件的“公共”访问修饰符。在“嵌入式​​资源”上更改 resx 的构建操作属性。

所以,我做到了,但没有任何改变。我检查了所有命名空间。好像没问题。我不知道,我还应该尝试什么。

在 .cs 中,我可以毫无错误地做到这一点

  var res = Properties.Resources.Res1;
Run Code Online (Sandbox Code Playgroud)

有人知道,有什么问题吗?

c# wpf resources xaml resx

5
推荐指数
1
解决办法
3040
查看次数

标签 统计

c# ×1

resources ×1

resx ×1

wpf ×1

xaml ×1