private static void ComparerProperty_PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (!(d is CollectionViewSource source)) { return; } if (e.OldValue == null) { ViewSort._viewDescriptor.AddValueChanged(source, ViewSort.Source_ViewChanged); } else if (e.NewValue == null) { ViewSort._viewDescriptor.RemoveValueChanged(source, ViewSort.Source_ViewChanged); } ViewSort.TrySetComparer(source, (IComparer?)e.NewValue); }
private static void Source_ViewChanged(object sender, EventArgs e) { CollectionViewSource source = (CollectionViewSource)sender; ViewSort.TrySetComparer(source, ViewSort.GetComparer(source)); }