locked
disabling gesture recognizer for a span in a label RRS feed

  • Question

  • User394483 posted

    I have a label inside a frame, the frame is clickable and the label contains a clickable link, before adding the gesture recognizer to the span that contains the link the whole frame was clickable including over the label but when I added the gesture recognizer for the span that contains the link now the link works but the frames gesture recognizer doesnt work when clicking over the label (on the text thats not a link), it still works when I click on the padding (not over the label but still inside the frame) so is there a way to still have the clicks over the text thats not a link to register as a click on the frame? adding the gesture recognizer on the span that contains the link kind of disabled clicking on the rest of the text. thanks in advance! (Im using c# and not xaml)

    Tuesday, October 20, 2020 1:23 AM

Answers

  • User369979 posted

    Try to add an extra gesture for your label like: <Frame> <Label> <Label.FormattedText> <FormattedString> <Span Text="Red Bold, " TextColor="Red" FontAttributes="Bold" /> <Span Text="default, " Style="{DynamicResource BodyStyle}"> <Span.GestureRecognizers> <TapGestureRecognizer Tapped="TextTapped" /> </Span.GestureRecognizers> </Span> <Span Text="italic small." FontAttributes="Italic" FontSize="Small" /> </FormattedString> </Label.FormattedText> <Label.GestureRecognizers> <TapGestureRecognizer Tapped="LabelTapped"/> </Label.GestureRecognizers> </Label> <Frame.GestureRecognizers> <TapGestureRecognizer Tapped="FrameTapped"/> </Frame.GestureRecognizers> </Frame> Fire the same code as what FrameTapped did in the frame's gesture.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, October 20, 2020 7:41 AM

All replies

  • User378073 posted

    There is a tap gesture on Frame and it works, There is tap gesture in one of the span in label and that also works , but you want Tap gesture on other spans as well? Is that the issue? If so just add the tap gesture on label instead of spans or add tap gesture in each span.

    Tuesday, October 20, 2020 4:21 AM
  • User394483 posted

    @stXamDev said: There is a tap gesture on Frame and it works, There is tap gesture in one of the span in label and that also works , but you want Tap gesture on other spans as well? Is that the issue? If so just add the tap gesture on label instead of spans or add tap gesture in each span.

    what I want is for the tap gesture of the frame to work over the normal text (not the link)

    Tuesday, October 20, 2020 4:28 AM
  • User378073 posted

    Can you post your current Xaml, and maybe an image of UI.

    Tuesday, October 20, 2020 4:32 AM
  • User369979 posted

    Try to add an extra gesture for your label like: <Frame> <Label> <Label.FormattedText> <FormattedString> <Span Text="Red Bold, " TextColor="Red" FontAttributes="Bold" /> <Span Text="default, " Style="{DynamicResource BodyStyle}"> <Span.GestureRecognizers> <TapGestureRecognizer Tapped="TextTapped" /> </Span.GestureRecognizers> </Span> <Span Text="italic small." FontAttributes="Italic" FontSize="Small" /> </FormattedString> </Label.FormattedText> <Label.GestureRecognizers> <TapGestureRecognizer Tapped="LabelTapped"/> </Label.GestureRecognizers> </Label> <Frame.GestureRecognizers> <TapGestureRecognizer Tapped="FrameTapped"/> </Frame.GestureRecognizers> </Frame> Fire the same code as what FrameTapped did in the frame's gesture.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, October 20, 2020 7:41 AM
  • User394483 posted

    @LandLu said: Try to add an extra gesture for your label like: <Frame> <Label> <Label.FormattedText> <FormattedString> <Span Text="Red Bold, " TextColor="Red" FontAttributes="Bold" /> <Span Text="default, " Style="{DynamicResource BodyStyle}"> <Span.GestureRecognizers> <TapGestureRecognizer Tapped="TextTapped" /> </Span.GestureRecognizers> </Span> <Span Text="italic small." FontAttributes="Italic" FontSize="Small" /> </FormattedString> </Label.FormattedText> <Label.GestureRecognizers> <TapGestureRecognizer Tapped="LabelTapped"/> </Label.GestureRecognizers> </Label> <Frame.GestureRecognizers> <TapGestureRecognizer Tapped="FrameTapped"/> </Frame.GestureRecognizers> </Frame> Fire the same code as what FrameTapped did in the frame's gesture.

    adding a third gesture recognizer worked! thank you very much

    Friday, October 23, 2020 7:55 PM