-
Notifications
You must be signed in to change notification settings - Fork 2
Cheat sheet
Jecho Jekov edited this page Nov 26, 2017
·
3 revisions
Install the NuGet package for the WPF projects that need to be localized. Alternatively, compile the source code and add reference to the WpfLocalization.dll assembly.
Add localized text, images and other resources to Properties/Resources.resx (C#) or My Project/Resources.resx (VB.NET) (alternatively go to Project -> Properties -> Resources).
Then use resource names with the Loc extension: <SomeElement Property="{Loc [Resource Name]}"/> (see below).
<TextBlock Text="{Loc Text_HelloWorld}"/><Image Source="{Loc Image_CapitalPhoto}"/><TextBlock Text="{Loc Text_HelloUser, Binding={Binding UserName}}"/>
<TextBlock Text="{Loc StringFormat='{}{0:d}', Binding={Binding BirthDate}}"/>LocalizationManager.CurrentCulture = CultureInfo.GetCulture("en-US");
LocalizationManager.CurrentUICulture = CultureInfo.GetCulture("en-US");<Window ... LocalizationScope.UICulture="{CultureInfo en-US}" LocalizationScope.Culture="{CultureInfo en-US}"><Window ... LocalizationScope.ResourceManager="{ResourceManager AssemblyName='SomeAssembly', ResourceFile='SomeAssembly.Properties.SomeResources'}"><Window ... xmlns:properties="clr-namespace:SomeAssembly.Properties" LocalizationScope.ResourceManager="{ResourceManager Type={x:Type properties:SomeResources}}"><Window ... LocalizationScope.ResourceManager="{LocalResourceManager SomeResources}">