private IncrementalUpdater FindUpdater() { if (this.updater != null) { return(this.updater); } DependencyObject ancestor = this.associatedObject; while (ancestor != null) { DependencyObject parent = VisualTreeHelper.GetParent(ancestor); ListViewBase listView = parent as ListViewBase; if (listView != null) { IncrementalUpdater currentUpdater = IncrementalUpdateBehavior.GetIncrementalUpdater(listView); if (currentUpdater == null) { currentUpdater = new IncrementalUpdater(); IncrementalUpdateBehavior.SetIncrementalUpdater(listView, currentUpdater); } return(currentUpdater); } ancestor = parent; } return(null); }
private static void OnPhaseChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { IncrementalUpdateBehavior behavior = (IncrementalUpdateBehavior)sender; IncrementalUpdater incrementalUpdater = behavior.FindUpdater(); FrameworkElement frameworkElement = behavior.associatedObject as FrameworkElement; if (incrementalUpdater != null && frameworkElement != null) { incrementalUpdater.UncachePhaseElement(frameworkElement, (int)args.OldValue); incrementalUpdater.CachePhaseElement(frameworkElement, (int)args.NewValue); } }