UIElementCollection.Contains method

Applies to Windows and Windows Phone

Determines whether an element is in the collection.

Syntax


public bool Contains(
  UIElement item
)

Parameters

item

Type: UIElement

The item to find in the collection.

Return value

Type: System.Boolean

true if the item was found in the collection; otherwise, false.

Remarks

All UIElement objects are reference objects, so you only get a true result if you pass another item reference to the same object that exists in the UIElementCollection.

You can also call IndexOf to get the index of a specific item in the collection. If the element you specify doesn't exist, IndexOf returns -1, so that's another way to determine that the collection doesn't contain a given element.

If you are programming using Visual C++ component extensions (C++/CX), there is no equivalent for Contains. You should iterate through the collection by calling First, and check each item for equality against the element you are looking for.

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
IndexOf

 

 

Show:
© 2014 Microsoft