我有以下情形:其中包含了一年中的月份Silverlight的組合框和的SelectedItem
1清單:
public List<String> Months
{
get
{
return m_Months;
}
}
m_Months = new List<String>();
for (int i = 1; i <= 12; i++)
{
DateTime date = new DateTime(1900, i, 1);
m_Months.Add(date.ToString("MMM"));
}
1組合框,其ItemsSource綁定到數月的列表,其SelectedIndex的是綁定的財產一個月,這是一個字符串:
public string Month
{
get
{
return m_Month;
}
set
{
if (value != m_Month)
{
m_Month = value;
NotifyPropertyChanged("Month");
}
}
}
<ComboBox SelectedItem="{Binding Month, Mode=TwoWay}" ItemsSource="{Binding Months}" />
當我從代碼隱藏,即月=「五一」設定年份,這是正確地傳送到ComboBox,和GETT呃月訪問,但組合框不會顯示'五月',因爲它是選定的項目。
我想知道:這是Silverlight 3中的錯誤嗎?當我使用Telerik的RadComboBox時,它工作正常。
乾杯, 弗朗西斯
希望他們有它在Silverlight 4中修復,但感謝張貼這個答案。 – Aligned 2010-04-26 18:12:15