Collection gets the item of wrong type for the IndexOf.Probably I found the reason for this odd behavior. Here's the code DataGrid.ScrollIntoView (decompile from Resharper)internal void ScrollIntoView(ItemsControl.ItemInfo info) { if (this.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated) this.OnBringItemIntoView(info); else this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, (Delegate) new DispatcherOperationCallback(((ItemsControl) this).OnBringItemIntoView), (object) info); }Here you cast info to the object type.But ItemsControl has two overloads for OnBringItemIntoView:one for ItemInfo and the second for object type.internal object OnBringItemIntoView(object arg) { return this.OnBringItemIntoView(this.NewItemInfo(arg, (DependencyObject) null, -1)); }So you get ItemInfo wrapped in ItemInfo. That's why this.LeaseItemInfo(info, true) recieves incorrect item and calls IndexOf with worng value:info.Index = this.Items.IndexOf(info.Item);
Visual Studio/Team Foundation Server/.NET Framework Tooling Version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results