public override object ProvideValue(IServiceProvider serviceProvider) { //modify the binding by setting the converter BindTo.Converter = new ConcatString { InitString = AttachString }; return(BindTo.ProvideValue(serviceProvider)); }
//{ // get { return (string)GetValue(HeaderTextProperty); } // set { SetValue(HeaderTextProperty, value); } //} public override object ProvideValue(IServiceProvider serviceProvider) { //modify the binding by setting the converter //string s = BindUno.ToString(); BindTo.Converter = new ConcatString { InitString = HeaderText }; return(BindTo.ProvideValue(serviceProvider)); }
public void Bind(Control control, string propertyName, object attachObject, string attachPropertyName, Func <object, object> callback = null) { if (this.binds.Has(b => b.Equals(propertyName, attachObject, attachPropertyName, callback))) { return; } //アタッチされる自分のプロパティ情報 PropertyInfo pInfo = control.GetProperty(propertyName); if (pInfo == null) { return; } //アタッチする外部オブジェクトのプロパティ名 PropertyInfo attachInfo = null; if (!string.IsNullOrEmpty(attachPropertyName)) { attachInfo = attachObject.GetProperty(attachPropertyName); if (attachInfo == null) { return; } } else if (callback == null) { return; } //バンド情報 BindTo bind = new BindTo() { BindControl = control, BindPropertyName = propertyName, BindProperty = pInfo, AttachObject = attachObject, AttachPropertyName = attachPropertyName, AttachProperty = attachInfo, ValueCallback = callback }; //必要なインタフェイスへキャスト if (attachObject is INotifyPropertyChanged notify) { //バインド情報の保持 this.binds.Add(bind); //プロパティの変更をキャッチ notify.PropertyChanged += Notify_PropertyChanged; } }