IXamlDirect.InsertIntoCollectionAt(Object, UInt32, Object) Method

Definition

Inserts a value into the specified IXamlDirect collection at the specified index.

This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

C#
public void InsertIntoCollectionAt(object xamlDirectObject, uint index, object value);

Parameters

xamlDirectObject
Object

Refers to the specific IXamlDirect collection.

index
UInt32

Refers to the index in the collection where the specified value must be inserted.

value
Object

Refers to the IXamlDirect value to add to the collection.

Examples

The following example shows how to insert a value into a collection at a specific index using XamlDirect APIs.

C#
XamlDirect xd = XamlDirect.GetDefault();

IXamlDirect relativePanel = xd.CreateInstance(XamlTypeIndex.RelativePanel);

IXamlDirect childrenCollection = xd.GetXamlDirectObjectProperty(relativePanel, XamlPropertyIndex.Panel_Children);

IXamlDirect button = xd.CreateInstance(XamlTypeIndex.Button);
xd.InsertIntoCollectionAt(childrenCollection, 0, button);
CPP
XamlDirect^ xd = XamlDirect::GetDefault();

IXamlDirect^ relativePanel = xd->CreateInstance(XamlTypeIndex::RelativePanel);

IXamlDirect^ childrenCollection = xd->GetXamlDirectObjectProperty(relativePanel, XamlPropertyIndex::Panel_Children);

IXamlDirect^ button = xd->CreateInstance(XamlTypeIndex::Button);
xd->InsertIntoCollectionAt(childrenCollection, 0, button);

Applies to

Táirge Leaganacha
WinUI 2 2.0, 2.1, 2.2, 2.3, 2.4, 2.5-prerelease, 2.5, 2.6-prerelease, 2.6, 2.7-prerelease, 2.7, 2.8-prerelease, 2.8

See also