Skip to main content
Logo Appt Light

Accessibility link on Xamarin

Links should be accessible for users of assistive technologies. When accessibility is not taken into account, users might not be able to find or activate links.

In Xamarin, you need to follow four steps to create links:

  1. Set the TextColor and TextDecoration properties of the Label or Span.

  2. Add a TapGestureRecognizer to the GestureRecognizers collection of the Label or Span, whose Command property binds to a ICommand, and whose CommandParameter property contains the URL to open.

  3. Define the ICommand that will be executed by the TapGestureRecognizer.

  4. 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>

Feedback?

Let us know!