Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Hyperlink Label text is not showing mouse Hand cursor after hovering on it in Xamarin

$
0
0

I am using CustomRenderer to make the Label text as the hyperlink. With my code Label is showing Underlined and we are using Label.GestureRecognizers to capture the click. But the mouse cursor is not showing Hand after hovering on the hyperlink text.

Below is the code that we are using:

Shared Project:

  • HyperlinkLabel.cs:

    namespace HyperlinkLabelControl
    {
         public class HyperLinkLabel : Label
            {
            }
    }
    
  • MainPage.xaml:

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:local="clr-namespace:HyperlinkLabelControl"
                 x:Class="HyperlinkLabelControl.MainPage">
        <ContentPage.Content>
            <StackLayout>
                <local:HyperlinkLabel Text="MyHyperLinkLabel" >
                    <Label.GestureRecognizers>
                        <TapGestureRecognizer
                            Command="{Binding BindingContext.MyClickedCommand, Source={x:Reference List}}"
                            CommandParameter="{Binding .}" />
                    </Label.GestureRecognizers>
                    </local:HyperlinkLabel>
            </StackLayout>
        </ContentPage.Content>
    </ContentPage>
    

UWP Project:

  • HyperLinkLabelRenderer.cs:

    [assembly: ExportRenderer(typeof(HyperLinkLabel), typeof(HyperLinkLabelRenderer))]
    namespace HyperlinkLabelControl.UWP.Renderers
    {
        public class HyperLinkLabelRenderer : LabelRenderer
        {
            protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
            {
                base.OnElementChanged(e);
                if (Control != null)
                    Control.TextDecorations = TextDecorations.Underline;
            }
        }
    }
    

Please provide the approch with that the Mouse Cursor will show Hand after hovering on Hyperlink Text in Xamarin.


Viewing all articles
Browse latest Browse all 77050

Trending Articles