This is a migrated thread and some comments may be shown as answers.

Localisation: Binding column headers to DynamicResources

3 Answers 225 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nicole
Top achievements
Rank 1
Nicole asked on 15 Nov 2010, 03:40 PM
Hello,

I am currently implementing a localization in our application. The headers of the columns and all captions of all controls are referenced to dynamic resources like that:

<telerik:GridViewDataColumn DataMemberBinding="{Binding ArtikelNr}" Header="{DynamicResource ArtikelNr}" IsReadOnly="True"/>


I am switching the culture during runtime with this function:

public class ResourceManager
    {
        public static void SetResources(Collection<ResourceDictionary> collection, CultureInfo culture)
        {
            RemoveOld(collection);
 
            try
            {
                Uri resource = new Uri("Resources/Strings_" + culture.Name + ".xaml", System.UriKind.Relative);
                collection.Add(new ResourceDictionary { Source = resource });
            }
            catch
            {
                // TODO: Handle this, is it possible to be here?
            }
        }
 
        private static void RemoveOld(Collection<ResourceDictionary> collection)
        {
            for (int i = 0; i < collection.Count; ++i)
            {
                if (collection[i].Source.ToString().Contains("Strings_"))
                {
                    collection.RemoveAt(i);
                    --i;
                }
            }
        }
 
        public static List<CultureInfo> SupportedCultures
        {
            get
            {
                return new List<CultureInfo>()
                {
                    new CultureInfo("de-DE"), // DEU
                    new CultureInfo("ru-RU"), // ENU
                };
            }
        }
    }


public void SetCulture(CultureInfo culture)
{
    Thread.CurrentThread.CurrentCulture = culture;
    Thread.CurrentThread.CurrentUICulture = culture;
    ResourceManager.SetResources(Resources.MergedDictionaries, culture);
}

The column headers of the gridview are ignoring the dynamic resources. But the resources are correctly added to the MergedDictionaries-Collection. All other controls (RadControls too) are using the dynamic resources fine.

Do have any ideas what's going wrong with the columns?

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 17 Nov 2010, 02:25 PM
Hi Josef,

May you check if the strings and their keys used in the xaml are the equal ? Is that behavior only for the columns headers or for all visible elements ? Is it possible to send us a sample application that we could debug and test locally ?
 

Regards,
Maya
the Telerik team
See What's New in RadControls for WPF in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
0
Nicole
Top achievements
Rank 1
answered on 19 Nov 2010, 01:12 PM
Hello Maya,

thank you for your answer. I have uploaded the sample application on my webspace. There it is: http://www.hammer-of-darkness.com/hypersurf/Translation.zip

Use the combobox to change the language between russian and german. The columnheaders of the gridview don't change their text/caption.
0
Maya
Telerik team
answered on 24 Nov 2010, 05:05 PM
Hello Josef,

In order to accomplish your scenario, you may follow up the idea demonstrated in our demos - both for the examples with Localization and modifying the Theme. Its main idea is that the element changing the language/theme is outside the main view - in the examples it is outside the main grid. In your case the RadComboBox may be defined outside and on changing of the selected item, reload a RadGridView with the appropriate language resources.

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
GridView
Asked by
Nicole
Top achievements
Rank 1
Answers by
Maya
Telerik team
Nicole
Top achievements
Rank 1
Share this question
or