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
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
>