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)); }
/// <summary> /// Updates the relative source value. /// </summary> public void UpdateSource([NotNull] object target) { if (target == null) { throw BindingExceptionManager.InvalidBindingTarget(RelativeSourceNode.Path); } var path = RelativeSourceNode.Path ?? String.Empty; if (!String.IsNullOrEmpty(Path)) { path = BindingExtensions.MergePath(path, Path); } if (RelativeSourceNode.Type != RelativeSourceExpressionNode.SelfType) { if (RelativeSourceNode.Type == RelativeSourceExpressionNode.MemberSourceType) { target = BindingServiceProvider.ContextManager.GetBindingContext(target); } else { target = new ParentSourceValue(target, RelativeSourceNode); } } IObserver observer = BindingServiceProvider.ObserverProvider.Observe(target, BindingPath.Create(path), false); _bindingSource = new BindingSource(observer); }