找不到“资源"在wpf文件 [英] Can't find "Resources" file in wpf

查看:74
本文介绍了找不到“资源"在wpf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm newbe in WPF. I need to add reference on the resources file resx and get strings from it.

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

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

I got an error: The name "Resources" does not exist in the namespace "clr-namespace:SelectObjectsWindow.Properties". I was searching information about this and find couple of advises: Set "public" access modifier of resx file. Change Build Action property of resx on "Embedded Resource".

所以,我做到了,但是什么都没有改变.我检查了所有名称空间.似乎还可以.我不知道,我还应该尝试什么.

So, I did it, but nothing changed. I checked all namespaces. Seems to be ok. I don't know, what else I should try.

在.cs中,我可以做到无误

In .cs i can do this without error

  var res = Properties.Resources.Res1;

有人知道,怎么了?

推荐答案

将访问修饰符从内部更改为公共,您的绑定将起作用.

Change access modifier from internal to public, your binding will work.

这篇关于找不到“资源"在wpf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆