ItemsSource binded to Dictionary datatype using Resource files

3 posts, 0 answers
  1. Jennifer
    Jennifer avatar
    1 posts
    Member since:
    Oct 2011

    Posted 13 Oct 2011 Link to this post

    There are combo boxes all over the app that are experiencing the same issue.  This combo box in particular is bound to a Dictionary which is loaded based on the current language the user has selected in their preferences of the application.  Normal text fields etc are display the correct translation from the correct resource file.  Placing a breakpoint in code shows the correct translated values in the MyTypes, however, from the UI the combo box ItemsSource are always displayed in English.

    How can I get the correct translated item from the resource file to be display in the combo box?

    Visual Studion 2010

    public Dictionary<string, string> MyTypes
    get { return myTypes; }
    public void InitializeCriteria(SelectionCriteria criteria)
    var culture = Thread.CurrentThread.CurrentUICulture.ToString();
    base.InitializeStandardSelectionCriteria(criteria, culture);
    // Load the Types
    var mTypes = MyTypes.Select(c => new Tuple<string, string>(c.Key, c.Value));
    Array.ForEach(mTypes.ToArray(), criteria.MyTypes.Add);
    var defaultMyType = criteria.MyTypes.FirstOrDefault();
    if (defaultMyType != null)
    criteria.MyTypes= defaultMyType .Item1;

    protected override void OnInitialize(ESEntities entities)
    void LoadMyTypes(ESEntities entities)
     myTypes = new Dictionary<string, string>()
      { "" , Resources.Resources.NoneLabel },
      { "D", Resources.Resources.DMessage },
      { "F", Resources.Resources.FMessage},
      { "H", Resources.Resources.HMessage },
      { "I", Resources.Resources.IMessage },
      { "L", Resources.Resources.LMessage } };


    <GroupBox x:Name="LGroup" Header="{x:Static Resources:Resources.OptionsL}">
               <telerik:RadComboBox x:Name="attenuationComboBox"
                     ToolTip="{x:Static Resources:Resources.OptionsDesired}" Height="23"
                     VerticalAlignment="Top"  ItemsSource="{Binding Criteria.MyTypes, Mode=OneWay,
                     NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True,UpdateSourceTrigger=PropertyChanged}"
                     SelectedValue="{Binding Criteria.MyType, Mode=TwoWay}"
                     IsEnabled="{Binding SelectionOptions.CEnabled}" DisplayMemberPath="Item2" SelectedValuePath="Item1" />






  2. Valeri Hristov
    Valeri Hristov avatar
    2252 posts

    Posted 17 Oct 2011 Link to this post

    Hello Jennifer,

    Are you able to achieve what you need with a standard WPF ComboBox control? I am afraid that I will not be able to help much without a simple application that can be used to observe the problem. If we have such application we will try to modify it so it works the way you need it.

    All the best,
    Valeri Hristov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Woshi
    Woshi avatar
    1 posts
    Member since:
    Nov 2011

    Posted 02 Nov 2011 Link to this post

    So interesting. I'm kinda interested... maybe I'll re-read twilight.

Back to Top