Functionality21.xaml.cs 1.28 KB
Newer Older
Mattia's avatar
Mattia committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
using System;
using System.Collections.Generic;
using SampleApp.DependencyServices;
using Xamarin.Forms;

namespace SampleApp.Views
{
    public partial class Functionality21 : ContentPage
    {
        IScreenReaderEnabled screenReaderEnabled;
        public Functionality21()
        {
            InitializeComponent();

            screenReaderEnabled = DependencyService.Resolve<IScreenReaderEnabled>();

            Label q = new Label
            {
                Text = "Is Screen Reader Active?",
            };

            Label y = new Label
            {
                Text = "",
                TextColor = Color.Green,
            };

            Label n = new Label
            {
                Text = "",
                TextColor = Color.Red,
            };

            background.Children.Add(q);
            background.Children.Add(y);
            background.Children.Add(n);
            AutomationProperties.SetIsInAccessibleTree(q, true);
            AutomationProperties.SetIsInAccessibleTree(y, true);
            AutomationProperties.SetIsInAccessibleTree(n, true);

            if (screenReaderEnabled.IsScreenReaderEnabled())
            {
                y.Text = "YES";
            }
            else
            {
                n.Text = "NO";
            }
        }
    }
}