1

I'm developing a WPF Application where the user is able to change the Language at runtime. In C# Code (ViewModels etc.) I'm using the reference to the resource. For example:

string translation = ScreenResources.WorkpieceDiameter;

This is supporting Intellisense and compile time errors. In XAML Code I'm using WPF Localization Extension:

Header="{lex:LocText xxxx.ScreenResources.WorkpieceDiameter}"

The Problem now is that in XAML Code I'm using a 'magic string', so if the resource name changes or move to another resource there wont be any compile time erros. Also the effort developing without intellisense member listing increases.

Is it possible to use the resource with a static reference static like in C# Code without using the advantage of WPF Loc Extension?

Johannes Wanzek
  • 2,825
  • 2
  • 29
  • 47

1 Answers1

0

Not sure why the need for an extension. I just do this:-

Header="{x:Static ns:ScreenResources.WorkpieceDiameter}"

Where 'ns' is the namespace of the resource file, added at the start of the XAML.

Andrew Stephens
  • 9,413
  • 6
  • 76
  • 152