Xamarin表单检查可访问性集中于元素

问题描述 投票:0回答:1

是否有一种方法可以检测元素何时获得屏幕阅读器的可访问焦点?像听众一样?有没有办法像我自己创建这样的侦听器?我想做的是在某个元素(例如包含图像的框架)获得焦点时播放声音,而不是读取其辅助功能名称。

xamarin.forms focus accessibility screen-readers
1个回答
0
投票

我们可以创建一个侦听器,以获取控件的焦点事件。

例如:我有一个名为txtUserName的Entry控件。因此,我们可以在xaml.cs文件中像下面这样编码。

    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
    }
© www.soinside.com 2019 - 2024. All rights reserved.