我有以下情况:
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 个 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}" />
当我从代码隐藏中设置年份时,即 Month =“May”,这会正确传播到 ComboBox,并访问 Month 的 getter,但 ComboBox 不会显示“May”,因为它是选定的项目。
我想知道:这是 Silverlight 3 中的错误吗?当我使用 Telerik 的 RadComboBox 时,它工作正常。
干杯,弗朗西丝