Get values from *.resx files in XAML

0x49D1 picture 0x49D1 · May 27, 2010 · Viewed 77.5k times · Source

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.

Answer

Julien Lebosquain picture Julien Lebosquain · May 27, 2010

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

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