private GetNode ( |
||
element | ||
return |
private static void OnSourceErrorsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var node = Scope.GetNode(d) as InputNode; if (node == null) { // this happens when disposing return; } var oldErrors = (ReadOnlyObservableCollection <ValidationError>)e.OldValue; if (ShouldTrack(oldErrors)) { CollectionChangedEventManager.RemoveHandler(oldErrors, node.OnSourceErrorsChanged); } var newErrors = (ReadOnlyObservableCollection <ValidationError>)e.NewValue; node.ErrorCollection.Remove(oldErrors); node.ErrorCollection.Add(newErrors); if (ShouldTrack(newErrors)) { CollectionChangedEventManager.AddHandler(newErrors, node.OnSourceErrorsChanged); } }
private static void OnSourceErrorsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (Scope.GetNode(d) is InputNode node) { if (e.OldValue is ReadOnlyObservableCollection <ValidationError> oldErrors && !ReferenceEquals(oldErrors, ErrorCollection.EmptyValidationErrors)) { CollectionChangedEventManager.RemoveHandler(oldErrors, node.OnSourceErrorsChanged); node.ErrorCollection.Remove(oldErrors); } if (e.NewValue is ReadOnlyObservableCollection <ValidationError> newErrors && !ReferenceEquals(newErrors, ErrorCollection.EmptyValidationErrors)) { CollectionChangedEventManager.AddHandler(newErrors, node.OnSourceErrorsChanged); node.ErrorCollection.Add(newErrors); } } }