【发布时间】:2009-06-09 02:45:21
【问题描述】:
我有以下场景:
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-list,其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 时,它工作正常。
干杯, 弗朗西丝
【问题讨论】:
标签: c# silverlight-3.0