views:

434

answers:

2

How to bind resources string to Xaml in silverlight?

+3  A: 

You need to add this reference to the App.xaml

xmlns:sys="clr-namespace:System;assembly=mscorlib"

Then you need to add the string into the <Application.Resources> section

<sys:String x:Key="ResourceString">Resource String</clr:String>

Then all you need to do is refer to *{StaticResource ResourceString} for example:

<TextBlock Text="{StaticResource ResourceString}"></TextBlock>
Jon Morley-Jones
A: 

Been a while since this was asked and answered, I just wanted to add an additional answer as the first one is not entirely correct. I think he's asking for resources, aka. text written in .resx files. It doesn't make sense at all to add individual strings into the StaticResources collection in the application.

I blogged recently on how to simplify the way you work with resources in Silverlight, enabling both automatic update when the culture changes and a dependency property which gives you simpler syntax.

http://sondreb.com/blog/post/Simplifying-Text-Resources-in-Silverlight.aspx

SondreB