Accessibility link - Xamarin
In Xamarin, you need to follow four steps to create links:
- Set the
TextColor
andTextDecoration
properties of theLabel
orSpan
. - Add a
TapGestureRecognizer
to theGestureRecognizers
collection of theLabel
orSpan
, whoseCommand
property binds to aICommand
, and whoseCommandParameter
property contains the URL to open. - Define the
ICommand
that will be executed by theTapGestureRecognizer
. - Write the code that will be executed by the
ICommand
.
For more information, see Xamarin Hyperlinks, it includes information how you can create your own Hyperlink
class.
<Label>
<Label.FormattedText>
<FormattedString>
<Span Text="Read more about " />
<Span Text="Appt"
TextColor="Blue"
TextDecorations="Underline">
<Span.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TapCommand}"
CommandParameter="https://appt.org" />
</Span.GestureRecognizers>
</Span>
</FormattedString>
</Label.FormattedText>
</Label>