XamlDirect.ClearCollection(IXamlDirectObject) 方法

定义

从指定的 IXamlDirectObject 集合中删除所有项。

public:
 virtual void ClearCollection(IXamlDirectObject ^ xamlDirectObject) = ClearCollection;
void ClearCollection(IXamlDirectObject const& xamlDirectObject);
public void ClearCollection(IXamlDirectObject xamlDirectObject);
function clearCollection(xamlDirectObject)
Public Sub ClearCollection (xamlDirectObject As IXamlDirectObject)

参数

xamlDirectObject
IXamlDirectObject

引用特定的 IXamlDirectObject 集合。

示例

以下示例演示如何添加 以使用 ClearCollection 方法清除指定 IXamlDirectObject 指向的集合。

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

xd.ClearCollection(childrenCollection);
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);

xd->ClearCollection(childrenCollection);

适用于

另请参阅