using Xamarin.Forms; ... var container = new StackLayout(); container.Children.Add(new Label { Text = "Element 0" }); container.Children.Add(new Label { Text = "Element 1" }); container.Children.Add(new Label { Text = "Element 2" }); var element1 = container.ElementAt(1); element1.TextColor = Color.Red;
using System.Linq; using Xamarin.Forms; ... var container = new FlexLayout(); container.Wrap = FlexWrap.Wrap; container.Direction = FlexDirection.Row; container.AlignContent = FlexAlignContent.Start; var elements = Enumerable.Range(0, 10) .Select(i => new BoxView { Color = Color.Blue }) .ToList(); foreach (var element in elements) container.Children.Add(element); var firstRow = container.Children.Take(3); foreach (var element in firstRow) element.BackgroundColor = Color.Yellow;In this example, a FlexLayout is created and ten BoxView elements are added as children. The ElementAt method is not used directly, but the efficient Linq method Take is used to retrieve the first three child elements. These elements are then highlighted by changing their BackgroundColor property to yellow. Package/Library: Xamarin.Forms.