public void OnItemsReset2() { if (SpatialIndex != null) { SpatialIndex.ExtentChanged -= OnSpatialExtentChanged; SpatialIndex.QueryInvalidated -= OnSpatialQueryInvalidated; } RealizedItems = null; SpatialIndex = null; PrivateIndex = null; if (base.IsVirtualizing && base.IsItemsHost && base.ItemsOwner != null) { RealizedItems = new LinkedList <int>(); SpatialIndex = (base.ItemsOwner.ItemsSource as ISpatialItemsSource); if (SpatialIndex == null) { PrivateIndex = new PrivateSpatialIndex(); PrivateIndex.Reset((base.ItemsOwner.Items != null) ? base.ItemsOwner.Items.Count : 0); SpatialIndex = PrivateIndex; } SpatialIndex.ExtentChanged += OnSpatialExtentChanged; SpatialIndex.QueryInvalidated += OnSpatialQueryInvalidated; } InvalidateReality(); InvalidateExtent(); }
/// <summary> /// Resets and initializes our spatial indices when the items source has changed. /// </summary> private void OnItemsReset() { if (SpatialIndex != null) { SpatialIndex.ExtentChanged -= OnSpatialExtentChanged; SpatialIndex.QueryInvalidated -= OnSpatialQueryInvalidated; } RealizedItems = null; SpatialIndex = null; PrivateIndex = null; if (IsVirtualizing && IsItemsHost && ItemsOwner != null) { RealizedItems = new LinkedList<int>(); SpatialIndex = ItemsOwner.ItemsSource as ISpatialItemsSource; if (SpatialIndex == null) { PrivateIndex = new PrivateSpatialIndex(); PrivateIndex.Reset(ItemsOwner.Items != null ? ItemsOwner.Items.Count : 0); SpatialIndex = PrivateIndex; } SpatialIndex.ExtentChanged += OnSpatialExtentChanged; SpatialIndex.QueryInvalidated += OnSpatialQueryInvalidated; } InvalidateReality(); InvalidateExtent(); }