ItemsControl calls IndexOf method of bound collection passing internal class ItemsControl.ItemInfo - by Voronin_Pavel

Status : 

 


1
0
Sign in
to vote
ID 776253 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/10/2013 7:49:09 AM
Access Restriction Public

Description

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);
Sign in to post a comment.
Posted by Microsoft on 1/16/2013 at 11:02 AM
This was previously reported internally. A fix was recently released. See "WPF Issue 4" at http://support.microsoft.com/kb/2750149
Posted by Helen [MSFT] on 1/15/2013 at 12:20 AM
I've received your file. I am sorry for the inconvenience. We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Voronin_Pavel on 1/14/2013 at 12:34 AM
Which update do you need? I've added source code to reproduce the problem. What else should I do?
Posted by Helen [MSFT] on 1/14/2013 at 12:30 AM
I am currently standing by for an update from you and would like to know how things are going on your end. If you could get back to me at your earliest convenience with information I request, we will be able to make headway towards a resolution. I look forward to hearing from you.
Posted by Helen [MSFT] on 1/10/2013 at 10:49 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Macy [MSFT] on 1/10/2013 at 7:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)