XAML globalization using resources in combobox
c#, localization, windows-8, winrt-xaml, xaml
Solution
As far as I know when you use in xaml that is a compile time constant which will not be able to change at runtime and bind to a resource. That is why you probably see Default1 or Default2 as items in your combobox.
I was able to find a solution to your problem.
The idea is that in the combobox you should use ComboBoxItem and set the x:Uid to the value of the resource. But in the resource file, the actual name should be Name.Content, because ComboBoxItem has a ContentPresenter in it as default and not a TextBlock.
So this is the code that worked for me: In the resource file I have:
Combo.Content ComboBox1
And in the Xaml I used:
<ComboBox>
<ComboBoxItem x:Uid="Combo" />
</ComboBox>
This will populate the ComboBox with an item "ComboBox1" (from the resource file).
I have not tested this to see if it works with resource files for different languages, but I see no reason why it should not work.
Problem
I am globalizing my WinRT app and I can't use language resources in my comboboxs. I can use it in my TextBlocks using Text property but not using x:string. What am I doing wrong? ``` TextBlock x:Uid="Priority" Text="Default"></TextBlock> <ComboBox> <x:String x:Uid="Color">Default1</x:String> <x:String x:Uid="Color.Text">Default2</x:String> </ComboBox> ``` EDIT Why can't I populate ComboBox elements with resource strings in XAML code? I know that I can add TextBlock elements inside ComboBox to use dictionaries or, as I am doing now, load them through code but this is not the response to my question.