How to: Add Resources to a Silverlight-based Application
Microsoft Silverlight will reach end of support after October 2021. Learn more.
This topic explains how you can use Visual Studio to add localized resource files, define the default culture, and specify supported cultures for your application.
To add resources to your application
Determine the default culture for your application. It should be region-neutral. For example, "en" represents the region-neutral English language and "ru" represents the region-neutral Russian language.
Add a resource to your Visual Studio project to hold the default culture's resources:
In Solution Explorer, right-click the project name, point to Add, and then click New Item.
In the Add New Item dialog box, under Templates, click Resources File and assign the resource file a meaningful name, such as "StringLibrary" for a resource file that contains string resources.
Add the appropriate resources to it.
Add one resource file to your project for each region-neutral culture or specific culture that your application supports by repeating step 2 for each culture. Name each resource file by using the root name of the resource file for the default culture, followed by a period and the culture name. (See CultureInfo for a list of region-neutral and specific culture names supported by the .NET Framework for Silverlight.) For example, if the default culture's resource file is named StringLibrary.resx, an application that has localized German language resources might have resource files named StringLibrary.de.resx and StringLibrary.de-DE.resx. Note that all satellite assemblies should be added to the same project. During the compilation process, Visual Studio includes the default culture's resource file in your application's main assembly, and it automatically creates separate assemblies for each region-neutral and specific culture for which you create a resource file.
Define the default culture for your application:
In Solution Explorer, right-click the project name, point to Application, and then click Assembly Information.
In the Neutral Language list, select the default culture, which should be a region-neutral language, such as "en", "fr", "es", or "ru". This modifies the application's assembly information file (either AssemblyInfo.vb or AssemblyInfo.cs), by adding a NeutralResourcesLanguageAttribute attribute that defines the name of the default culture.
In Solution Explorer, right-click the project name, and then click Unload Project to close the project while leaving the project icon visible.
In Solution Explorer, right-click the project name, and then click Edit.
The project file opens in the Visual Studio XML Editor.
In the project file, add the names of the region-neutral and specific cultures whose satellite assemblies your application has created to the <SupportedCultures> tag. If your application supports multiple cultures, use a semicolon (;) to separate their names. This list of cultures should not include your application's default culture. For example, a <SupportedCultures> tag for an application whose default culture is English ("en") and that supports the English - United States ("en-US"), French ("fr"), French - France ("fr-FR"), Russian ("ru"), and Russian - Russia ("ru-RU") cultures might appear as follows:
In Solution Explorer, right-click the project name, and then click Reload Project.