July 14, 2009

I had to find the way to use images as a RESX resources – this actually was second question of the person who asked me about forcing the rebinding.

Before starting, some theory about RESX usage in Silverlight.

Silverlight support usage of RESX files and localization via “SupportedCultures” attribute in CSPROJ file. The attribute itself even exists in project created with Silverlight 3 Tools, but for some reason there is no interface to change the cultures (or at least I didn’t found them). So the only way (for me) to change this attribute is via text editing the CSPROJ file.

<SupportedCultures>de,he,ru</SupportedCultures>

After this attribute set, if we will use RESX files with standard .NET localization naming convention (<RESOURCE_NAME>.resx for culture neutral resources and <RESOURCE_NAME>.<LANGUAGE>.resx for language depended resorces) Visual Studio will compile resources and will create satellite assemblies for supported cultures.

The “System.Drawing.Bitmap” does not exists in Silverlight, thus the application will not compile. From other hand, if Visual Studio will not identify the resource (unknown resource type) it will generate following code:

hi,
greetings for the day
i created strings.resx and strings.ja.resx
but my silverlight textblock shows only english content from strings.resx but its not showing japanese content from strings.ja i have also mentioned the ja-JP in uiculture of aspx page but it doesnt show the japanese content from strings.ja.resx

What if i have to change the language on a button click event.suppose i have 2 buttons one for english and another for portuguese Cliking on any one will change the applications labels content accordingly.