You can use x:Uid
to associate the control id with the string resource identifier:
< Button x:Name="Button1" x:Uid="Button1" />
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi all,
I'm working on a class library which contains several .resw resource files and pages. The question is, how to fetch the string for UI component properties.
For example, I have a class library called "lib", which has a resource file UIResource.resw which has a resource "Button1.Content", the value for "Button1.Content" is "OK". There is also a page in the class library, named "Page1" which has a button named "Button1", now in Page1.xaml, if I'd like to use "OK" for Button1's content, how should I process?
Note: the button may be in a datatemplate in a GridView, so fetch the resource in C# code may not be a good idea.
Did I make it clear enough? If not, please feel free to ask. Any help would be appreciated, thank you.
Alex
You can use x:Uid
to associate the control id with the string resource identifier:
< Button x:Name="Button1" x:Uid="Button1" />
Problem solved. Use following code to access resource in a class lib:
Thanks for replying. But sorry, no, this won't work. Actually this is what I'm doing now. Let me try to make it more clear in another way.
I got a solution with multiple projects. Two of them are:
UWPProject --which is a uwp project, the start up project. Relies on LibProject .
LibProject --which is a class library. Containing a resw resource file UIResource.resw, and a page class Page1.
What I'm going to achieve, is to fetch a defined string resource Button1.Content from UIResource.resw, and use it for a button control in Page1. Here is what I'm doing now:
In this case, the Content property of Button1, is always an empty string. What I can guess is that, the application was trying to fetch the string resource from UWPProject which is the start up project and different than LibProject. So how can I fetch the resource in LibProject?
Note again: the button may be in a datatemplate in a GridView, so fetch the resource in C# code may not be a good idea.