question

ericxuan avatar image
0 Votes"
ericxuan asked RoyLi-MSFT commented

How to load local strings from a Class Library or a Windows Runtime Library in Xaml with u:id

I found a method "Load strings from a Class Library or a Windows Runtime Library" in the .cs file, like this: https://docs.microsoft.com/en-us/windows/uwp/app-resources/localize-strings-ui-manifest, but how to do it in Xaml with u: id.

u: id now works only if you place localization strings files in the same class library as Xaml, what can I do?

It took a long long time to find a way, but can not find it.


windows-uwp-xaml
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have to say that after checking the document, you can't do that in XAML. You have to do it in the CS file.

0 Votes 0 ·

1 Answer

ericxuan avatar image
0 Votes"
ericxuan answered RoyLi-MSFT commented

I have solved this problem by setting a custom attached property.

you can do it:

var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView("ContosoControl/Resources");
this.myXAMLTextBlockElement.Text = resourceLoader.GetString("exampleResourceName");

get a text from the .resw file

then you can set a value on your control

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Glad to hear that you have solved your issue and it is appreciated for you to share your solution here. Please accept your reply as answer so and this could help others who are facing the same issue.

0 Votes 0 ·