Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load string resource for textblock x:Uid in code behind

I have a string resource that I'm using to set as the x:uid for a textblock

<data name="Expected.Text" xml:space="preserve">
    <value>Expected Text</value>
</data>

<TextBlock x:Name="control" x:uid="Expected />

I'm trying to write a Unit test to check if the text is correct. However I can't get a handle on the "Expected" string because it has a .text at the end so that it can be displayed in the TextBlock

ResourceLoader loader = ResourceLoader.GetForCurrentView();
var expected = loader.GetString("Expected");
Assert.AreEqual(expected, control.Text);

This code fails because var expected is blank

like image 371
Frank Sposaro Avatar asked Oct 29 '14 00:10

Frank Sposaro


1 Answers

You can access that property via the following notation:

var expected = loader.GetString("Expected/Text");

Source: https://docs.microsoft.com/en-us/windows/uwp/app-resources/localize-strings-ui-manifest#refer-to-a-string-resource-identifier-from-code

like image 163
Fred Avatar answered Nov 14 '22 23:11

Fred