IXamlDirect.GetCollectionCount(Object) 方法

定义

返回指定 IXamlDirect 集合中的项计数。

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

public:
 unsigned int GetCollectionCount(Platform::Object ^ xamlDirectObject);
uint32_t GetCollectionCount(IInspectable const& xamlDirectObject);
public uint GetCollectionCount(object xamlDirectObject);
Public Function GetCollectionCount (xamlDirectObject As Object) As UInteger

参数

xamlDirectObject
Object

Platform::Object

IInspectable

指特定的 IXamlDirect 集合。

返回

UInt32

unsigned int

uint32_t

项计数。

示例

以下示例演示如何通过 IXamlDirect 的实例获取 Panel.Children 计数。

XamlDirect xd = XamlDirect.GetDefault();

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

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

uint count = xd.GetCollectionCount(childrenCollection);
XamlDirect^ xd = XamlDirect::GetDefault();

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

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

UINT count = xd->GetCollectionCount(childrenCollection);

适用于