Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-use-a-resourcedictionary-to-manage-localizable-string-resources.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.4 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Use a ResourceDictionary to Manage Localizable String Resources 03/30/2017
csharp
vb
resources [WPF], packaging string resources
packaging string resources [WPF]
ResourceDictionary [WPF]
localization [WPF], packaging string resources
19e7d9a5-20df-4ad3-b157-fe6515902e5e

How to: Use a ResourceDictionary to Manage Localizable String Resources

This example shows how to use a xref:System.Windows.ResourceDictionary to package localizable string resources for Windows Presentation Foundation (WPF) applications.

To use a ResourceDictionary to manage localizable string resources

  1. Create a xref:System.Windows.ResourceDictionary that contains the strings you would like to localize. The following code shows an example.

    [!code-xamlStringLocalizationSample#StringResourceDictionary]

    This code defines a string resource, localizedMessage, of type xref:System.String, from the xref:System namespace in mscorlib.dll.

  2. Add the xref:System.Windows.ResourceDictionary to your application, using the following code.

    [!code-xamlStringLocalizationSample#ReferencingStringResourceDictionary]

  3. Use the string resource from markup, using [!INCLUDETLA#tla_xaml] like the following.

    [!code-xamlStringLocalizationSample#GetLocalizedResourceFromMarkup]

  4. Use the string resource from code-behind, using code like the following.

    [!code-csharpStringLocalizationSample#GetLocalizedResourceFromCode] [!code-vbStringLocalizationSample#GetLocalizedResourceFromCode]

  5. Localize the application. For more information, see Localize an Application.