DependencyObjectCollection.First Method


Returns the iterator for iteration over the items in the collection.

Equivalent WinUI method: Microsoft.UI.Xaml.DependencyObjectCollection.First.

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



The iterator object. The iterator's current position is at the 0-index position, or at the collection end if the collection is empty.



You can iterate through a DependencyObjectCollection in C# or Microsoft Visual Basic. In many cases, such as using foreach syntax, the compiler does this casting for you and you won't need to cast to IEnumerable<DependencyObject> explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable with a DependencyObject constraint.

Applies to