public static IObserver CreateBindingSource(RelativeSourceInfo node, IDataContext context, [NotNull] object target, string pathEx) { if (target == null) { throw BindingExceptionManager.InvalidBindingTarget(node.Path); } string path = node.Path ?? string.Empty; if (!string.IsNullOrEmpty(pathEx)) { path = MergePath(path, pathEx); } if (node.Type != RelativeSourceInfo.SelfType) { if (node.Type == RelativeSourceInfo.ContextSourceType) { target = BindingServiceProvider.ContextManager.GetBindingContext(target); } else { target = new ParentSourceValue(target, node); } } return(CreateBindingSource(context, path, target, false)); }
public ParentSourceValue(object target, RelativeSourceInfo node) { _node = node; _isElementSource = _node.Type == RelativeSourceInfo.ElementSourceType; _targetReference = ServiceProvider.WeakReferenceFactory(target); _value = Empty.WeakReference; IBindingMemberInfo rootMember = BindingServiceProvider.VisualTreeManager.GetRootMember(target.GetType()); if (rootMember != null) { _subscriber = rootMember.TryObserve(target, this); } TryHandle(null, null); }