共用方式為


IXamlDirect.ClearCollection(Object) 方法

定義

從指定的 IXamlDirect 集合中移除所有專案。

本檔適用于 Windows 應用程式 SDK 中適用于 WinUI 的 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);

適用於

另請參閱