* net-current-v30plus-md.md * net-current-v40plus-md.md * tla2sharptla-ui-md.md * tla2sharptla-uiautomation-md.md * tla2sharptla-winclient-md.md * tla2sharptla-xaml-md.md * tlasharptla-ui-md.md * tlasharptla-uiautomation-md.md * tlasharptla-winclient-md.md * tlasharptla-xaml-md.md * fix warnings
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 |
|
|
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
-
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. -
Add the xref:System.Windows.ResourceDictionary to your application, using the following code.
[!code-xamlStringLocalizationSample#ReferencingStringResourceDictionary]
-
Use the string resource from markup, using Extensible Application Markup Language (XAML) like the following.
[!code-xamlStringLocalizationSample#GetLocalizedResourceFromMarkup]
-
Use the string resource from code-behind, using code like the following.
[!code-csharpStringLocalizationSample#GetLocalizedResourceFromCode] [!code-vbStringLocalizationSample#GetLocalizedResourceFromCode]
-
Localize the application. For more information, see Localize an Application.