Skip to content

wbokkers/uwp-xbindable-resource-strings

Repository files navigation

x-Bindable Resource Strings

A type-safe alternative to x:Uid resource string bindings.

I don't like x:Uid for binding resource strings to the user interfaces. It uses 'magic strings'. This is a major cause of hard to catch runtime errors. The compiler will not detect if resource strings have been renamed or removed. And you won't get IntelliSense to help you choose from the available string resources. For x:Uid to work, you also need to add control property information to the string resource keys. This makes it harder to reuse the same string in different contexts.

Fortunately, there's a solution!!

In this UWP-project, a T4 template generates static properties for each string. See the MainPage for a usage example.

Changing resource strings is easy:

  • Change the resource files (Strings.resw)
  • Save the changed resource files
  • Right click on R.tt and choose 'Run Custom Tool'
  • Rebuild the project.

About

A type-safe alternative to x:Uid resource string bindings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages