9
我試圖用一對字符串填充ComboBox
,值爲。我做到了,在後面的代碼是這樣的:如何在XAML中填充組合框
listCombos = new List<ComboBoxItem>();
item = new ComboBoxItem { Text = Cultures.Resources.Off, Value = "Off" };
listCombos.Add(item);
item = new ComboBoxItem { Text = Cultures.Resources.Low, Value = "Low" };
listCombos.Add(item);
item = new ComboBoxItem { Text = Cultures.Resources.Medium, Value = "Medium" };
listCombos.Add(item);
item = new ComboBoxItem { Text = Cultures.Resources.High, Value = "High" };
listCombos.Add(item);
combo.ItemsSource = listCombos;
ComboBoxItem:
public class ComboBoxItem
{
public string Text { get; set; }
public object Value { get; set; }
public override string ToString()
{
return Text;
}
}
正如你所看到的,我將用我的ResourceDictionary
的Text
值。但是如果我這樣做,當我在運行時更改語言時,ComboBox
內容不會。
所以我想嘗試填寫我的ComboBox
在設計(在XAML)。
所以我的問題是:如何填寫我的ComboBox
一對文本,價值像上面?
這正是解決方案!謝謝! :) – Sonhja 2013-02-28 08:33:16