/// <summary> /// Control's OnPropertyBound event handler extension. /// </summary> /// <param name="prop">Property object.</param> /// <param name="row">The data row context, if in a list.</param> public virtual void OnPropertyBound(DateTimeProperty prop, DataRow row) { if (BaseBinding.Create(txt_DateTime) is BasePropertyBinding pb) { pb.BindTo(prop, row); } }
public void RemoveBinding(BaseBinding binding) { if (binding == null) { return; } bindings.Remove(binding); }
public void AddBinding(BaseBinding binding) { if (binding == null) { return; } RemoveBinding(binding); bindings.Add(binding); }
public void RiseProperty(string parameter_name, object variable = null) { for (int i = 0; i < bindings.Count; ++i) { BaseBinding curr_binding = bindings[i]; if (curr_binding.BindingName != parameter_name) { continue; } curr_binding.RiseValue(variable); } }
public Type?InferDataContextTypeFromBindings(IEnumerable <IDataBinding> bindings, Type?currentGenericArg) { foreach (var binding in bindings) { switch (binding) { case DeferredPropertyBinding deferredPropertyBinding: switch (deferredPropertyBinding.TargetPropertyName) { case nameof(IItemsControl.ItemsSource) when currentGenericArg != null: var sourceProp = BaseBinding.GetBindingProperty(currentGenericArg, deferredPropertyBinding.SourcePropertyName); if (!(sourceProp?.PropertyType is { } sourcePropType) || !typeof(IEnumerable).IsAssignableFrom(sourcePropType) || !sourcePropType.IsGenericType) { continue; } var srcPropGenerics = sourcePropType.GetGenericArguments(); if (srcPropGenerics == null || srcPropGenerics.Length == 0) { continue; } if (srcPropGenerics.Length != 1) { throw new NotImplementedException(); } return(srcPropGenerics[0]); case nameof(IBindableElement.DataContext): if (currentGenericArg == null) { break; } var dcProp = BaseBinding.GetBindingProperty(currentGenericArg, deferredPropertyBinding.SourcePropertyName); if (dcProp is { } validProp) { return(validProp.PropertyType); } break; } break; } } return(currentGenericArg); }
public BindingsRegistry RegisterWithConfiguration(BaseBinding baseBinding) { bindings.Add(baseBinding, true); return(this); }
public BindingsRegistry Register(BaseBinding baseBinding) { bindings.Add(baseBinding, false); return(this); }
protected void OnEnable() { target_script = (BaseBinding)target; }