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

ItemsSource binded to Dictionary datatype using Resource files

2 Answers 240 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jennifer
Top achievements
Rank 1
Jennifer asked on 13 Oct 2011, 04:51 PM
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)
{
    base.OnInitialize(entities);
 
    LoadMyTypes(entities);
    LoadSomeOtherData(entities);
}
private
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" />
</GroupBox>

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 17 Oct 2011, 11:37 AM
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 >>

0
Woshi
Top achievements
Rank 1
answered on 03 Nov 2011, 03:16 AM
So interesting. I'm kinda interested... maybe I'll re-read twilight.

Tags
ComboBox
Asked by
Jennifer
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Woshi
Top achievements
Rank 1
Share this question
or