How to Override PropertyChangedCallback of a predefined Dependency Property ItemsSource in a WPF ItemsControl
Call OverrideMetadata in a static constructor of your derived ItemsSource class: public class MyItemsControl : ItemsControl { static MyItemsControl() { ItemsSourceProperty.OverrideMetadata( typeof(MyItemsControl), new FrameworkPropertyMetadata(OnItemsSourcePropertyChanged)); } private static void OnItemsSourcePropertyChanged( DependencyObject obj, DependencyPropertyChangedEventArgs e) { ((MyItemsControl)obj).OnItemsSourcePropertyChanged(e); } private void OnItemsSourcePropertyChanged(DependencyPropertyChangedEventArgs e) { var oldCollectionChanged = e.OldValue as INotifyCollectionChanged; var newCollectionChanged = e.NewValue as INotifyCollectionChanged; if (oldCollectionChanged … Read more