2
我公开了一个集合并将其绑定到了自动完成框的itemsource,但是选择或更改autocompletebox上的文本并不像文本框或标签那样更新模型!如何使用mvvm中的模型绑定自动完成框?
视图模型:
public ObservableCollection<String> SymptomsDb { get; private set; }
private String symptom;
public String Symptom
{
get { return symptom; }
set
{
symptom = value;
RaisePropertyChanged(() => this.Symptom);
}
}
public AnalysisViewModel()
{
List<String> s = new List<String>();
s.Add("test");
SymptomsDb = new ObservableCollection<String>(s);
}
观点:
<controls:AutoCompleteBox
ItemsSource="{Binding SymptomsDb}"
SelectedItem="{Binding Symptom}"
Text="{Binding Symptom}"
IsTextCompletionEnabled="True"
FilterMode="Contains"/>
谢谢。为了理解为什么控件不会将Text属性正确绑定到IDataErrorInfo类,我迷失了几个小时。 – andySF 2014-02-28 14:26:18