Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
574 views
in Technique[技术] by (71.8m points)

c# - Can't find "Resources" file in wpf

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>

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.

In .cs i can do this without error

  var res = Properties.Resources.Res1;

Do somebody know, what is wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...