/// <summary> /// Adds/removes and registers/unregisters events associated with <see cref="DataGridExtensions.ScrollAddedIntoViewProperty"/>, respectively. /// </summary> /// <param name="DataGrid"></param> /// <param name="Collection"></param> /// <param name="Register"></param> static void OnScrollAddedIntoViewChanged(DataGrid DataGrid, IObservableCollection Collection, bool Register) { var h = Collection.GetHashCode(); if (Register) { _ScrollAddedIntoView.Add(h, DataGrid); Collection.ItemAdded += OnScrollAddedIntoViewChanged; } else { Collection.ItemAdded -= OnScrollAddedIntoViewChanged; _ScrollAddedIntoView.Remove(h); } }