Localizing a WPF Application
This topic introduces steps and best practices to help you localize your Windows Presentation Foundation (WPF) applications.
Globalization and Localization
Globalization is the design and development of applications that perform in multiple locations. For example, globalization supports localized user interfaces and regional data for users in different cultures. WPF provides globalized design features that include automatic layout, satellite assemblies, and localized attributes and commenting.
Localization is the translation of application resources into localized versions for the specific cultures that the application supports. When you localize in WPF, you use the APIs in the System.Windows.Markup.Localizer namespace. These APIs are used by the LocBaml Tool Sample command-line tool. For more information about how to build and use LocBaml, see How to: Localize an Application.
Best Practices for WPF UI Design
When you design a WPF–based UI, consider implementing the following best practices.
Write your UI in XAML; avoid creating UI in code. When you create your UI by using XAML, you expose it through built-in localization APIs.
Avoid using absolute positions and fixed sizes to lay out content; instead, use relative or automatic sizing. For more information, see Layouts in the WPF Designer.
Use the SizeToContent property; and keep widths and heights set to Auto.
Avoid using the Canvas control to lay out UIs.
Use the Grid control and its size-sharing feature.
For more information, see WPF Globalization and Localization Overview.
Best Practices for WPF Localization
When you localize WPF–based applications, consider implementing the following best practices.
Use localization comments to provide extra context for localizers.
Use localization attributes to control localization instead of selectively omitting Uid properties on elements. For more information, see Localization Attributes and Comments.
Use msbuild /t:updateuid and /t:checkuid to add and check Uid properties in your XAML.
For more information, see WPF Globalization and Localization Overview.
See Also
Tasks
Walkthrough: Loading Resources from a Satellite Assembly
Concepts
How to: Localize an Application