天天看点

使您的Xamarin.Forms应用程序可访问

iOS,Android和Windows都会为开发人员公开API,为每个人构建可访问的移动应用。 我们很高兴地宣布,我们在Xamarin.Forms中添加了可用性的新API,以便开发人员更轻松地构建可访问的跨平台移动应用程序。 在这篇文章中,我们将介绍添加到Xamarin.Forms中的新API,从而轻松构建可访问的移动应用程序。

AutomationProperties.Hint

AutomationProperties.IsInAccessibleTree

AutomationProperties.LabeledBy

AutomationProperties.Name

点击(此处)折叠或打开

toolkit:EntryLine

        Text="{Binding Email}"

        Keyboard="Email"

        HorizontalOptions="FillAndExpand"

        Placeholder="email address"

        x:Name="EntryEmail"

        StyleId="EmailTextField"

        IsEnabled="{Binding IsNotBusy}"

        BorderColor="#ECECEC"

        AutomationProperties.Hint="Enter your email here"

        AutomationProperties.IsInAccessibleTree="true"

        AutomationProperties.Name="Email entry field">

        toolkit:EntryLine.HorizontalTextAlignment>

            OnPlatform x:TypeArguments="TextAlignment" iOS="Center"/>

        /toolkit:EntryLine.HorizontalTextAlignment>

/toolkit:EntryLine>

在启用辅助功能的物理设备上运行代码,并为用户提供为AutomationProperties.Hint提供的值。 这在iOS上使用VoiceOver 在Android上,一些控件,包括Button,不幸的是,由于与Android本身有关的原因,它们的行为不正确,尽管Slider等元素将读取“提示”和“名称”值的组合。

记住,您将需要将Xamarin.Forms 2.3.5添加到使用Xamarin.Forms的所有项目中,包括您的iOS和Android项目。 请注意,IntelliSense中的AutomationProperties属性可能不可用,因为它们是附加的属性。

继续阅读