Poli97
Poli97

Reputation: 304

Xamarin forms check accessibility focus on an element

Is there a way to detect when an element receives the focus of a screen reader? Like an event listener or some such? And there is a way like to create a listener like this on my own?

What I would like to do is to play a sound when a certain element (like a frame that contains an image) receives the focus, instead of reading the accessibility name.

Upvotes: 0

Views: 597

Answers (1)

hashimks
hashimks

Reputation: 1225

We can have a listener created for getting the focused event for a control.

eg: I have an Entry control named txtUserName. So we can code like below in the xaml.cs file.

    public MyPage()
    {
            InitializeComponent ();
            txtUserName.Focused += UserTextFocused;
            txtUserName.Unfocused += UserTextUnFocused;
    }

    private void UserTextFocused(object sender, EventArgs e)
    {
        //Do the required action
    }

    private void UserTextUnFocused(object sender, EventArgs e)
    {
        //Do the required action
    }

Upvotes: 1

Related Questions