Share via


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).

public:
 void InsertIntoCollectionAt(Platform::Object ^ xamlDirectObject, unsigned int index, Platform::Object ^ value);
void InsertIntoCollectionAt(IInspectable const& xamlDirectObject, uint32_t const& index, IInspectable const& value);
public void InsertIntoCollectionAt(object xamlDirectObject, uint index, object value);
Public Sub InsertIntoCollectionAt (xamlDirectObject As Object, index As UInteger, value As Object)

Parameters

xamlDirectObject
Object

Platform::Object

IInspectable

Refers to the specific IXamlDirect collection.

index
UInt32

unsigned int

uint32_t

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

value
Object

Platform::Object

IInspectable

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.

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);
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

See also