XamlDirect.AddToCollection(IXamlDirectObject, IXamlDirectObject) 方法

定义

将值添加到指定的 IXamlDirectObject 集合。

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)

参数

xamlDirectObject
IXamlDirectObject

引用特定的 IXamlDirectObject 集合。

value
IXamlDirectObject

引用要添加到集合的 IXamlDirectObject 值。

示例

以下示例演示如何使用 XamlDirect API 向集合添加值。

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

注解

IXamlDirectObject 是 Xaml 内部对象实例的最小句柄。 因此,集合和要添加到集合的值都是 IXamlDirectObject 类型。

适用于

另请参阅