private static SetErrors ( this element, ReadOnlyObservableCollection |
||
element | this | |
value | ReadOnlyObservableCollection |
|
return | void |
protected override void OnHasErrorsChanged() { var hasErrors = this.HasErrors; Scope.SetHasErrors(this.Source, hasErrors); this.UpdateErrors(); var parent = VisualTreeHelper.GetParent(this.Source); if (parent == null) { return; } var node = (Node)parent.GetValue(Scope.ErrorsProperty); if (hasErrors) { if (Scope.GetForInputTypes(parent)?.IsInputType(this.Source) == true) { if (node == null) { Scope.SetErrors(parent, new ScopeNode(parent, this)); } else { node.AddChild(this); } } } else { node?.RemoveChild(this); } }
public ScopeNode(DependencyObject source, IErrorNode child) : base(child) { this.sourceReference = new WeakReference <DependencyObject>(source); Scope.SetErrors(source, this); this.OnHasErrorsChanged(); }
protected override void OnHasErrorsChanged() { var source = this.Source; if (source == null) { return; } Scope.SetHasErrors(source, this.HasErrors); var parent = VisualTreeHelper.GetParent(source); var parentNode = parent == null ? null : (Node)Scope.GetErrors(parent); if (!this.HasErrors) { Scope.SetErrors(source, null); parentNode?.RemoveChild(this); } else if (parent != null) { if (parentNode == null) { Scope.SetErrors(parent, new ScopeNode(parent, this)); } else { parentNode.AddChild(this); } } }
internal static void Notify(ErrorNode errorNode) { var source = errorNode.Source; if (source == null) { return; } Scope.SetHasErrors(source, errorNode.HasErrors); var parent = VisualTreeHelper.GetParent(source); Node childNode = errorNode; while (parent != null) { if (Scope.GetForInputTypes(parent) == null) { break; } var parentNode = (Node)parent.GetValue(Scope.ErrorsProperty); if (ShouldRemoveChildNode(parentNode, childNode)) { parentNode.RemoveChild(childNode); if (parentNode is ScopeNode && parentNode.Children.Count == 0) { Scope.SetErrors(parent, null); } else { parentNode.RefreshErrors(); } } else if (ShouldAddChildNode(parent, childNode, source)) { if (parentNode == null) { parentNode = new ScopeNode(parent, childNode); Scope.SetErrors(parent, parentNode); } else { parentNode.AddChild(childNode); parentNode.RefreshErrors(); } } Scope.SetHasErrors(parent, parentNode?.HasErrors == true); childNode = parentNode; parent = VisualTreeHelper.GetParent(parent); } }