question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TapGestureRecognizer does not work in label's span

See original GitHub issue

Description

In the following xaml, tap does’t work and react to the finger tap.

        <Label>
            <Label.FormattedText>
                <FormattedString>
                    <Span Text="Alternatively, click " />
                    <Span Text="here"
              TextColor="Blue" FontSize="24"
              TextDecorations="Underline">
                        <Span.GestureRecognizers>
                            <TapGestureRecognizer Command="{Binding TapCommand}"
                                      CommandParameter="https://docs.microsoft.com/dotnet/maui/" />
                        </Span.GestureRecognizers>
                    </Span>
                    <Span Text=" to view .NET MAUI documentation." />
                </FormattedString>
            </Label.FormattedText>
        </Label>

Steps to Reproduce

create an maui app add label and some span add TapGestureRecognizer

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

Android 10、windows sdk 10.0.19041.0

Did you find any workaround?

no workaround. but TapGestureRecognizer in label works like the following xaml: <Label Text="here" TextColor="Blue" FontSize="24" TextDecorations="Underline"> <Label.GestureRecognizers> <TapGestureRecognizer Command="{Binding TapCommand}" CommandParameter="https://docs.microsoft.com/dotnet/maui/" /> </Label.GestureRecognizers> </Label>

Relevant log output

no

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:9
  • Comments:5

github_iconTop GitHub Comments

13reactions
yzbaicommented, Jun 17, 2022

This is annoying.

10reactions
bdcoder2commented, Sep 12, 2022

Copied and pasted the following code from the official docs at: https://docs.microsoft.com/en-us/dotnet/maui/user-interface/controls/label

<Label>
    <Label.FormattedText>
        <FormattedString>
            <Span Text="Alternatively, click " />
            <Span Text="here"
                  TextColor="Blue"
                  TextDecorations="Underline">
                <Span.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding TapCommand}"
                                          CommandParameter="https://docs.microsoft.com/dotnet/maui/" />
                </Span.GestureRecognizers>
            </Span>
            <Span Text=" to view .NET MAUI documentation." />
        </FormattedString>
    </Label.FormattedText>
</Label>

The Command never fires!! HOW do we set-up a hyperlink in .Net MAUI ??

PLEASE update code example or provide workaround.

Thanks in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Span.GestureRecognizers - TapGestureRecognizer not ...
The Label.GestureRecognizers fires the OnCounterClicked event on click. The Span.GestureRecognizers does not fire the OnCounterClicked event on ...
Read more >
TapGestureRecognizer doesn't work for Span inside Label ...
GestureRecognizers that it doesn't work for Span inside Label in MAUI .NET. You can ... As an alternative workaround, you can use Label....
Read more >
[SOLVED] TapGesture won't work with Span
so, I've encountered this issue - a tap gesture won't be triggered/fired on a Span - a while ago and now tried again...
Read more >
TapGestureRecognizer not working with Spans on iOS
Tap gesture not working on iOS devices below is the code. <Label Grid.Column="1" Padding="10" x:Name="lblPrivacyLink"> <Label.FormattedText>
Read more >
Span Label underline is not working on Xamarin iOS
I'm using a Label with Spans, one of them is a link and I want to add an underline style, I'm using <Span...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found