IXamlDirect.ClearCollection(Object) 方法

定义

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

本文档适用于 Windows 应用 SDKWinUI 的 WinUI 2 for UWP (,请参阅Windows 应用 SDK命名空间) 。

public:
 void ClearCollection(Platform::Object ^ xamlDirectObject);
void ClearCollection(IInspectable const& xamlDirectObject);
public void ClearCollection(object xamlDirectObject);
Public Sub ClearCollection (xamlDirectObject As Object)

参数

xamlDirectObject
Object

Platform::Object

IInspectable

指特定的 IXamlDirect 集合。

示例

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.AddToCollection(childrenCollection, button);

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

xd->ClearCollection(childrenCollection);

适用于

另请参阅