How to associate a resource string with Xaml in Silverlight

How do you bind a resource string to Xaml in Silverlight?

+3
source share
2 answers

You need to add this link in App.xaml

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

Then you need to add a line to the section <Application.Resources>

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

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

<TextBlock Text="{StaticResource ResourceString}"></TextBlock>
+6
source

Some time ago, when I was asked and answered, I just wanted to add an additional answer, since the first one is not entirely correct. I think he asks for resources, aka. text written in .resx files. It makes no sense to add individual rows to the StaticResources collection in the application.

, Silverlight, , , .

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

+2

Source: https://habr.com/ru/post/1707136/


All Articles