我有以下场景:
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"));
}
Run Code Online (Sandbox Code Playgroud)
1 ComboBox,其ItemsSource绑定到Months列表,其SelectedIndex绑定到属性Month,这是一个字符串:
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}" />
Run Code Online (Sandbox Code Playgroud)
当我从代码隐藏设置Year时,即Month ="May",这被正确地传播到ComboBox,并且访问了Month的getter,但是ComboBox没有显示'May'作为它的选择项.
我想知道:这是Silverlight 3中的一个错误吗?当我使用Telerik的RadComboBox时,它工作正常.
干杯,弗朗西斯