共用方式為


IXamlDirect.InsertIntoCollectionAt(Object, UInt32, Object) 方法

定義

將值插入指定的 IXamlDirect 集合中指定的索引處。

本檔適用于 Windows 應用程式 SDK 中適用于 WinUI 的 WinUI 2 for UWP (,請參閱Windows 應用程式 SDK命名空間) 。

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)

參數

xamlDirectObject
Object

Platform::Object

IInspectable

參考特定的 IXamlDirect 集合。

index
UInt32

unsigned int

uint32_t

參考集合中必須插入指定值的索引。

value
Object

Platform::Object

IInspectable

參考要新增至集合的 IXamlDirect 值。

範例

下列範例示範如何使用 XamlDirect API,將值插入集合中的特定索引。

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

適用於

另請參閱