UIElementCollection.Insert method

Applies to Windows and Windows Phone

Inserts an item into the collection at the specified index.

Syntax


public void Insert(
  int index, 
  UIElement item
)

Parameters

index

Type: System.Int32

The zero-based index at which item should be inserted.

item

Type: UIElement

The object to insert into the collection.

Remarks

The Insert method will throw an exception if you attempt to add a UIElement to a UIElementCollection and that UIElement already exists in the collection. The Windows Runtime enforces that no UIElement can be the child of more than one parent element, and trying to add the same item twice even to the same parent violates that enforcement.

To add an item to the end position in the collection, you can use the Add method. Calling Insert with an index value that is the same as the Count value is equivalent to calling Add.

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

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
Add
Item (indexer)

 

 

Show:
© 2014 Microsoft