Stefan Olsson
Stefan Olsson

Reputation: 647

C#, Properties using strings

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.

Upvotes: 3

Views: 207

Answers (1)

Shebin
Shebin

Reputation: 3468

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

Upvotes: 2

Related Questions