This documentation is archived and is not being maintained.

CollectionView.IndexOf Method

Returns the index at which the specified item is located.

Namespace: System.Windows.Data
Assembly: PresentationFramework (in presentationframework.dll)

public virtual int IndexOf (
	Object item
public int IndexOf (
	Object item
public function IndexOf (
	item : Object
) : int
You cannot use methods in XAML.



Return Value

The index at which the specified item is located, or -1 if the item is unknown.

If this method returns an index other than -1, it must always be true that view[index-1] < item <= view[index], where the comparisons are done using the Compare method of the view, if one exists.

This particular behavior of the method is used by some CollectionChanged event handlers to speed up reaction to insertion and deletion. If the subclass does not implement this method, a listener does a binary search using Compare.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0