3

C#, Visual studio 2010, Windows 7

When you set the image to WPF control image you can specifify the source to the image like this

/MyTest;component/images/Misc/bg.jpg

But how do you do with strings, I have a number of strings resources, for example, strings.resx, strings.sv-Se.resx etc. and want to use this "string concept" when specify the text to a button.

What should I write in the properties (or the XAML file for the window) to retrive the strings?

I have tried

/MyTest;component/strings.File

me:strings.File

But nothing seems to work.

Stefan Olsson
  • 617
  • 3
  • 16
  • 32
  • Depending on what you want to achieve (Localization?), [this](http://stackoverflow.com/questions/665764/how-to-fetch-string-from-resource-to-assign-in-wpf-resource-section-in-xaml) maybe what you're looking for or this question is even a duplicate of. – Christian.K Aug 10 '11 at 07:08

1 Answers1

2

set the access specifier of resx file be public

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:prop="clr-namespace:WpfApplication1.Properties"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <TextBox Text="{x:Static prop:Resources.String1}"/>


    </Grid>
</Window>

refrence : Accessing strings from resx file

Shebin
  • 3,310
  • 2
  • 24
  • 27
  • Hi Thanks a lot, that did the trick, your suggestion also led me to this site http://gargmanoj.wordpress.com/2009/03/18/accessing-strings-from-resource-file-in-xaml-markup/ Regards – Stefan Olsson Aug 10 '11 at 07:54