예제 #1
0
 /// <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;
 }
예제 #2
0
		/// <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;
		}
예제 #3
0
        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));
        }
예제 #4
0
        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);
        }
예제 #5
0
 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));
 }
예제 #6
0
 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));
 }
예제 #7
0
 /// <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)
 {
 }
예제 #8
0
 /// <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)
 {
 }