UIElementCollection.IndexOf method

Applies to Windows and Windows Phone

Determines the index of a specific item in the collection.

Syntax


public int IndexOf(
  UIElement item
)

Parameters

item

Type: UIElement

The object to locate in the collection.

Return value

Type: System.Int32

The index of item if found in the collection; otherwise, –1.

Remarks

IndexOf won't throw an exception if the element specified as item doesn't exist in the collection. Instead, it will return -1, which is a special value that isn't valid as a true index.

If you have an index for an element that exists in the collection but not a reference, you can use the Item (indexer) property of UIElementCollection to get or set a value by index.

If you are programming using Visual C++ component extensions (C++/CX), see IndexOf.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls

See also

UIElementCollection
Item (indexer)

 

 

Show:
© 2014 Microsoft