Search code examples
c#wpfuwpresourceswin-universal-app

print from resources (resw) directly in view on uwp | WPF


Hi guys i'm building a Universal Windows App for windows 10 IOT. So, I'didn't found a method to get a label value from resources file, directly from WPF.

There is a method like this:

<Button Content="{x:StaticResources local:mylabel" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Name="btnUpdate" Margin="0,200,0,0" MinWidth="300" Command="{Binding add}" /> 

on the "normal" WPF it's easy, but on universal windows app I didn't found a solution.

The resources file within on Resources folder in my solution, while the page it's in view folder.

Thanks


Solution

  • In UWP you can use x:Uid directive to associate a control with a string resource identifier:

    <Button x:Uid="mylabel" Name="btnUpdate" .... Command="{Binding add}" /> 
    

    Please refer to MSDN for more information: https://learn.microsoft.com/en-us/windows/uwp/app-resources/localize-strings-ui-manifest