Binding strings from a .resw file using ReswFileCodeGenerator in XAML

I tried to localize my Windows Universal application using multilingual application toolkit. Since you cannot bind strings directly from a .resw file in XAML, I used the ReswFileCodeGenerator tool. It works fine in the code behind, but in XAML I can't figure it out correctly.

In Windows Phone 8.0, I could use:

Text="{Binding Path=LocalizedResources.StringName, Source={StaticResource Strings}}"

Is there a similar way in Windows (Phone) 8.1 using the ReswFileGenerator tool?

+4
source share
3 answers

- , Depechie: x:Uid.

, . /. , XAML :

<TextBlock x:Uid="appString" />

:

var resourceLoader = new ResourceLoader();
var localizedText = resourceLoader.GetString("appString/Text");
+7

wp8.1 .resw x: Uid xaml!

<TextBlock x:Uid="FieldKey" />

...

+3

-, . , . . .exe - .

pre-build ( "\to\ResourcesHelper.exe" ):

call "path\to\ResourcesHelper.exe" "$(TargetName)" "$(ProjectDir)\" "$(RootNameSpace)" "universal"

, /en -US ( ).

, , LocalizedStrings.cs, - , .resx. , LC ( ), UC ( ) UCF ( ), . , .:)

. , , , .

+2

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


All Articles