using System; using System.Collections.Generic; using Xamarin.Forms; namespace SampleApp.Views { public partial class Functionality18 : ContentPage { StackLayout aggregateElements; Label agg1, agg2, agg3; public Functionality18() { InitializeComponent(); background.Padding = 10; //container for the aggregated views aggregateElements = new StackLayout { BackgroundColor = Color.DarkMagenta, HeightRequest = 150, Padding = 10, }; AutomationProperties.SetIsInAccessibleTree(aggregateElements, true); //the container that aggregates the views has to be accessible, setting his "AutomationProperties.IsInAccessibleTree" property to true if (Device.RuntimePlatform == Device.Android) { AutomationProperties.SetIsInAccessibleTree(aggregateElements, true); } background.Children.Add(aggregateElements); //here I create the single views to be aggregated into one single element //all the "Label" in Xamarin have "AutomationProperties.IsInAccessibleTree" property setted to false by default agg1 = new Label { Text = "View number 1", BackgroundColor = Color.Orange, HeightRequest = 40, }; AutomationProperties.SetIsInAccessibleTree(agg1, false); agg2 = new Label { Text = "View number 2", BackgroundColor = Color.Orange, HeightRequest = 40, }; AutomationProperties.SetIsInAccessibleTree(agg2, false); agg3 = new Label { Text = "This three different texts (views) have been grouped together, and will be seen as a single element.", BackgroundColor = Color.Orange, HeightRequest = 40, }; AutomationProperties.SetIsInAccessibleTree(agg3, false); aggregateElements.Children.Add(agg1); aggregateElements.Children.Add(agg2); aggregateElements.Children.Add(agg3); } private void groupAccessibleItems(Layout container) { String desc = ""; foreach (Label l in container.Children) { Console.WriteLine($"PIPPO: id={l.Text}"); AutomationProperties.SetIsInAccessibleTree(l, false); desc += l.Text; } Console.WriteLine($"PIPPO: totaldesc={desc}"); AutomationProperties.SetIsInAccessibleTree(container, true); AutomationProperties.SetName(container, desc); } protected override void OnAppearing() { if (Device.RuntimePlatform == Device.iOS) { groupAccessibleItems(aggregateElements); } } } }