Search code examples
c#xamllocalizationresx

Get values from *.resx files in XAML


Is it possible to add some value from resource file right into the XAML markup? Or for localization we always have to make something like this in *.cs file:

txtMessage.Text = Messages.WarningUserMessage;

Where Messages is resource, and txtMessage is TextBlock.


Solution

  • Make sure that Code Generation is set to Public in the resx editor, then you can simply use:

    <TextBlock Text="{x:Static Messages.WarningUserMessage}" />