結合我具有存儲型果實的對象的基本屬性:數據爲文本框
Fruit food;
public Fruit Food
{
get {return this.food;}
set
{
this.food= value;
this.RefreshDataBindings();
}
}
public void RefreshDataBindings()
{
this.textBox.DataBindings.Clear();
this.textBox.DataBindings.Add("Text", this.Food, "Name");
}
所以我設置this.Food
形式外,然後將其在用戶界面中顯示出來。
如果我修改this.Food
,它會正確更新。如果我以編程方式修改用戶界面,如:
this.textBox.Text = "NewFruit"
,它不更新此。食物。
這是爲什麼?我還爲Fruit.Name實施了INotifyPropertyChanged
,但仍然相同。
非常感謝♥ – 2017-10-27 15:25:46