我有ComboBox
和TextBox
。他们都通过SelectedValue
向Text
中的相应DataBinding
接收值(即properties
和ViewModel
)。
更改此SelectedValue
中的ComboBox
后,我想从TextBox
(List<string>
的一部分)填充此ViewModel
中的新值。
我不想在SelectedIndexChanged
使用event
ComboBox
来选择新的TextBox
。来自Text
的{{1}}的{{1}}。我怎么能这样做?
答案 0 :(得分:1)
在SelectedValue的setter中,您应该修改Text属性的值,并在Text的setter中触发PropertyChanged事件。
public string SelectedValue
{
get { return _selectedValue; }
set
{
_selectedValue = value;
//here write your code to modify the Text property
}
}
public string Text
{
get { return _text; }
set
{
_text = value;
RaisePropertyChanged(() => Text);
}
}