public BindingExpression(Binding binding, PropertyInfo targetProperty, object target) { if (binding == null) throw new ArgumentNullException("binding"); if (targetProperty == null) throw new ArgumentNullException("targetProperty"); if (target == null) throw new ArgumentNullException("target"); Binding = binding; Binding.Target = target; TargetProperty = targetProperty; if(string.IsNullOrEmpty(binding.TargetPath)) { binding.TargetPath = targetProperty.Name; } object source = Binding.Source; SourceProperty = source.GetType().GetNestedProperty(ref source, Binding.SourcePath, true); Binding.Source = source; }
public BindAttribute(string sourcePath, string targetPath) { Binding = new Binding(sourcePath, targetPath); }
public BindAttribute(string targetPath) { Binding = new Binding(null, targetPath); }
public BindAttribute() { Binding = new Binding(); }
public IBindingExpression SetBinding(string targetProperty, Binding binding) { return SetBinding(this, targetProperty, binding); }
public IBindingExpression SetBinding(IBindable target, string targetProperty, Binding binding) { return BindingOperations.SetBinding(target, targetProperty, binding); }
public static IBindingExpression SetBinding(IBindable target, string targetProperty, Binding binding) { if (target == null) throw new ArgumentNullException("target"); if (string.IsNullOrEmpty(targetProperty)) throw new ArgumentNullException("targetProperty"); if (binding == null) throw new ArgumentNullException("binding"); var binderKey =_Bindings.SingleOrDefault((kvp)=>kvp.Key.Object == target && kvp.Key.Property == targetProperty).Key; IBindingExpression bindingExpression = null; object nestedTarget = target; var element = target as Element; PropertyInfo propertyInfo = target.GetType().GetNestedProperty(ref nestedTarget, targetProperty, false); var targetReady = propertyInfo != null && nestedTarget != null; if (targetReady) { if (_BindingExpressions == null) _BindingExpressions = new List<IBindingExpression>(); bindingExpression = GetBindingExpression(target, targetProperty); if (bindingExpression == null) { bindingExpression = new BindingExpression(binding, propertyInfo, nestedTarget) { Element = element }; _BindingExpressions.Add(bindingExpression); var INPC = bindingExpression.Binding.Source as INotifyPropertyChanged; if (INPC != null) { INPC.PropertyChanged -= HandleDataContextPropertyChanged; INPC.PropertyChanged += HandleDataContextPropertyChanged; } } } else { if (binderKey == null) _Bindings.Add(new PropertyBinder() { Object = target, Property = targetProperty }, binding); else _Bindings[binderKey] = binding; } return bindingExpression; }