/// <summary> /// Initializes a new instance of the ObjectBinding with the specified object and binding to get/set values with /// </summary> /// <param name="dataItem">object to get/set values from</param> /// <param name="innerBinding">binding to use to get/set the values from the dataItem</param> public ObjectBinding(object dataItem, IndirectBinding innerBinding) { this.DataItem = dataItem; this.InnerBinding = innerBinding; this.InnerBinding.Changed += HandleInnerBindingChanged; this.InnerBinding.Changing += HandleInnerBindingChanging; }
/// <summary> /// Initializes a new instance of the ObjectBinding with the specified object and binding to get/set values with /// </summary> /// <param name="dataItem">object to get/set values from</param> /// <param name="innerBinding">binding to use to get/set the values from the dataItem</param> public ObjectBinding (object dataItem, IndirectBinding innerBinding) { this.DataItem = dataItem; this.InnerBinding = innerBinding; this.InnerBinding.Changed += HandleInnerBindingChanged; this.InnerBinding.Changing += HandleInnerBindingChanging; }
public static DualBinding Bind(this Control control, IndirectBinding controlBinding, object objectValue, IndirectBinding objectBinding, DualBindingMode mode = DualBindingMode.TwoWay, object defaultControlValue = null, object defaultContextValue = null) { var valueBinding = new ObjectBinding(objectValue, objectBinding) { SettingNullValue = defaultContextValue, GettingNullValue = defaultControlValue }; return(Bind(control, controlBinding, valueBinding, mode)); }
public static DualBinding Bind(this ObjectBinding controlBinding, IndirectBinding dataContextBinding, DualBindingMode mode = DualBindingMode.TwoWay, object defaultControlValue = null, object defaultContextValue = null) { var control = controlBinding.DataItem as Control; if (control == null) { throw new ArgumentOutOfRangeException("controlBinding", "Binding must be attached to a control"); } var contextBinding = new ObjectBinding(control, new DelegateBinding <Control, object>(w => w.DataContext, null, (w, h) => w.DataContextChanged += h, (w, h) => w.DataContextChanged -= h)); var valueBinding = new ObjectBinding(control.DataContext, dataContextBinding) { GettingNullValue = defaultControlValue, SettingNullValue = defaultContextValue }; DualBinding binding = Bind(controlBinding: controlBinding, valueBinding: valueBinding, mode: mode); contextBinding.DataValueChanged += delegate { ((ObjectBinding)binding.Source).DataItem = contextBinding.DataValue; }; control.Bindings.Add(contextBinding); return(binding); }
public static DualBinding Bind(this Control control, IndirectBinding controlBinding, DirectBinding valueBinding, DualBindingMode mode = DualBindingMode.TwoWay) { return(Bind(controlBinding: new ObjectBinding(control, controlBinding), valueBinding: valueBinding, mode: mode)); }
public static DualBinding Bind(this Control control, IndirectBinding controlBinding, IndirectBinding dataContextBinding, DualBindingMode mode = DualBindingMode.TwoWay, object defaultControlValue = null, object defaultContextValue = null) { return(Bind(new ObjectBinding(control, controlBinding), dataContextBinding, mode, defaultControlValue, defaultContextValue)); }
/// <summary> /// Initializes a new instance of the ObjectBinding with the specified object and binding to get/set values with /// </summary> /// <param name="dataItem">object to get/set values from</param> /// <param name="innerBinding">binding to use to get/set the values from the dataItem</param> public ObjectBinding(object dataItem, IndirectBinding <TValue> innerBinding) : base(dataItem, innerBinding) { }
/// <summary> /// Initializes a new instance of the ObjectBinding with the specified object and binding to get/set values with /// </summary> /// <param name="dataItem">object to get/set values from</param> /// <param name="innerBinding">binding to use to get/set the values from the dataItem</param> public ObjectBinding(T dataItem, IndirectBinding innerBinding) : base(dataItem, innerBinding) { }