Bagikan melalui


XamlDirect.AddToCollection(IXamlDirectObject, IXamlDirectObject) Metode

Definisi

Menambahkan nilai ke koleksi IXamlDirectObject yang ditentukan.

public:
 virtual void AddToCollection(IXamlDirectObject ^ xamlDirectObject, IXamlDirectObject ^ value) = AddToCollection;
void AddToCollection(IXamlDirectObject const& xamlDirectObject, IXamlDirectObject const& value);
public void AddToCollection(IXamlDirectObject xamlDirectObject, IXamlDirectObject value);
function addToCollection(xamlDirectObject, value)
Public Sub AddToCollection (xamlDirectObject As IXamlDirectObject, value As IXamlDirectObject)

Parameter

xamlDirectObject
IXamlDirectObject

Mengacu pada koleksi IXamlDirectObject tertentu.

value
IXamlDirectObject

Mengacu pada nilai IXamlDirectObject untuk ditambahkan ke koleksi.

Contoh

Contoh berikut menunjukkan cara menambahkan nilai ke koleksi menggunakan API XamlDirect .

XamlDirect xd = XamlDirect.GetDefault();

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

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

IXamlDirectObject button = xd.CreateInstance(XamlTypeIndex.Button);
xd.AddToCollection(childrenCollection, button);
XamlDirect^ xd = XamlDirect::GetDefault();

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

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

IXamlDirectObject^ button = xd->CreateInstance(XamlTypeIndex::Button);
xd->AddToCollection(childrenCollection, button);

Keterangan

IXamlDirectObject adalah handel minimal untuk instans objek internal Xaml. Oleh karena itu, koleksi dan nilai yang akan ditambahkan ke koleksi keduanya adalah jenis IXamlDirectObject.

Berlaku untuk

Lihat juga