Isn't there anything like a LinkButton in Xamarin?
I want to create a label with the looks of an url link that once tapped opens the external browser.
I also need to know how to open the device's external browser (to open an specified url) in a Portable Project.
Thanks
The Xamarin.Forms
way to open an URL string in the default mobile browser:
Device.OpenUri(new Uri("http://example.com"))
While a Forms' Label
does not have a click event, you can add a TapGestureRecognizer
so when the label is tapped it executes Device.OpenUri
.
var myURLLabel = new Label
{
Text = "https://xamarin.com"
};
myURLLabel.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(() => {
Device.OpenUri(new Uri(myURLLabel.Text));
})
});
Xamarin-Forms-Labs' ExtendedLabel
allows you style a label's text as underlined....
Ref: https://github.com/XLabs/Xamarin-Forms-Labs/wiki/ExtendedLabel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With