private static void OnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { if (args.Property == AdornerProperties.LayoutProperty) { ((AdornerLayout)args.OldValue).AdornerPropertyChanged(sender, args); ((AdornerLayout)args.NewValue).AdornerPropertyChanged(sender, args); UIElement adorner = sender as UIElement; if (adorner == null) { return; } AdornerLayer adornerLayer = VisualTreeHelper.GetParent((DependencyObject)adorner) as AdornerLayer; if (adornerLayer == null) { return; } adornerLayer.OnLayoutChanged(adorner); } else { AdornerProperties.GetLayout(sender).AdornerPropertyChanged(sender, args); } }