【发布时间】:2014-03-21 13:33:06
【问题描述】:
我有一个问题,当我更新 Comboboxitem 上的文本时,它不会立即反映在 UI 上。必须单击组合框以显示项目(具有正确的文本)。任何想法为什么?请注意,这个确切的代码在 WPF 中完美运行
定义要显示的字符串的属性
public string NormallyOpenString
{
get
{
if (this.IsInput)
{
return "High";
}
else if (this.IsRelay)
{
return "Open";
}
else
{
return "Open (High)";
}
}
}
像这样绑定到组合框
<ComboBox SelectedIndex="{Binding Normally, Mode=TwoWay}" >
<ComboBoxItem Content="{Binding NormallyOpenString}" />
<ComboBoxItem Content="{Binding NormallyClosedString}" />
</ComboBox>
当另一个组合框更改时,我想更新文本,因为它更改了 IsInput / IsRelay 是什么。我通过NotifyPropertyChanged 这样做
this.NotifyPropertyChanged("NormallyOpenString");
this.NotifyPropertyChanged("NormallyClosedOpenString");
this.NotifyPropertyChanged("Normally");
【问题讨论】:
标签: c# wpf silverlight combobox