Monday, April 16, 2018

UWP: How do you access Page resources by code in an UWP app?

You can keep your resources, such as style, data etc. in different places on a page and then use them in your app either by declarative markup or using code.

This post shows how you may access resources in your "Page.Resources" using code.


PageResrcs_0

It has a resource which is a string and a key. The page has single TextBox named "txt1".
In the code behind you use the key to access the resource and send it to the text box.


PageResrcs_1

When you run the app this is what you see, the resource on the page appearing in the TextBox.



No comments: