using System; using System.Collections.Generic; using Xamarin.Forms; using SampleApp.DependencyServices; namespace SampleApp.Views { public partial class Functionality3 : ContentPage { IAssignFocus assignFocus; IScreenReaderEnabled screenReaderEnabled; Boolean focus = true; public Functionality3() { InitializeComponent(); assignFocus = DependencyService.Get(); screenReaderEnabled = DependencyService.Resolve(); AutomationProperties.SetIsInAccessibleTree(label, true); } void Button_Clicked(System.Object sender, System.EventArgs e) { if (screenReaderEnabled.IsScreenReaderEnabled()) { if (focus) { assignFocus.AssignFocus(label); label.Text = "I Have Focus"; button.Text = "Reset"; } else { assignFocus.AssignFocus(button); label.Text = "I Don't Have Focus"; button.Text = "Assign focus to the label above"; } focus = !focus; } } } }