How to: Make XAML Content Localizable WPF application
You may want to localize your XAML content by supplying resource string for XML attributes.
For example you may want to change Content of a button :
<Button Content="Search"> </Button>
To Make Content Localizable
For example you may want to change Content of a button :
<Button Content="Search"> </Button>
To Make Content Localizable
- Create a new resource file.
- Make the access modifier of the resource file to public.
- create a class that has a public constructor Define a property that points to the resources.
- Open the App.xml file and add the following to the <Application.Resources> section:
- To make the Content Localizable; replace the string with
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocalizedStrings | |
{ | |
public LocalizedStrings() | |
{ | |
} | |
private static SilverlightApp.Resource1 resource1 = new SilverlightApp.Resource1(); | |
public SilverlightApp.Resource1 Resource1 { get { return resource1; } } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Application.Resources> | |
<local:LocalizedStrings xmlns:local ="clr-namespace:appNamespace" | |
x:Key="LocalizedStrings" /> | |
</Application.Resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{Binding Path=resourceFile.resourceName, Source={StaticResource LocalizedStrings }} |