http://blogs.wankuma.com/rti/archive/2008/06/06/141854.aspx
データバインドの着火方法
の続き・・・と言うかメモ。
foreach(Binding x in this.DataBindings)
とゴリゴリ書く必要はなかったです。
以下、なぐり書きコード。
public class MyTextBox : TextBox
private string _Value;
[Bindable(BindableSupport.Default)]
public string Value {
get { return this._Value; }
set {
if (this._Value == value) reurn;
this._Value = value;
NortifyPropertyChanged("Value")
}
}
private void NortifyPropertyChanged(string propertyName) {
var q =
from Binding p in this.DataBindings
where
p.IsBinding &&
p.DataSourceUpdateMode == DataSourceUpdateMode.OnPropertyChanged &&
p.PropertyName == propertyName
select p;
if (q.Count() == 0) return;
q.First().WriteValue();
}
}
赤字の部分は、必要に応じて変更した方が良いところです。
#ちょっと修正しましたw