Share via


UIElementCollection.First 方法

定義

傳回可逐一查看 UIElementCollection中專案的反覆運算器物件。

public:
 virtual IIterator<UIElement ^> ^ First() = IIterable<UIElement ^>::First;
IIterator<UIElement> First();
public IIterator<UIElement> First();
function first()
Public Function First () As IIterator(Of UIElement)

傳回

反覆運算器物件。 反覆運算器的目前位置位於 0 索引位置,如果集合是空的,則位於集合結尾。

實作

備註

用來保存 First 所傳回反覆運算器的便利方式,就是將傳回值指派給使用 自動 類型推算關鍵字宣告的變數。 然後使用 IIterator API 作為 while 迴圈的一部分。 例如:

auto iterator1{ uieCollection.First() };
while (iterator1.HasCurrent())
{
    Windows::UI::Xaml::UIElement currentItem{ iterator1.Current() };
    // Your logic here that does something with currentItem.
    iterator1.MoveNext();
}
auto iterator1 = uieCollection->First();
while (iterator1->HasCurrent)
{
    auto currentItem = iterator1->Current;
    //your logic here that does something with currentItem
    iterator1->MoveNext();
}

適用於

另請參閱