Search code examples
c#.netwpfsilverlight

How to access resource file's value in code behind


In the xml I am able to access resource file's value by providing the corresponding key. First I have added the namespace as following

xmlns:res="clr-namespace:WpfApplication3.Properties"

And then bind the Text using following way

Text="{x:Static res:Resources.city}"

But in my same application I have to use it in code behind. What should I do it to access my resource file?

When I count the key of my resource file I found it 0 that does not make any sense as I have many keys in my resource file.


Solution

  • This should be as simple as:

    var cityName = Properties.Resources.city;