Adam Pedley posted a nice solution for converting html to a Label https://xamarinhelp.com/hyperlink-in-xamarin-forms-label/?utm_campaign=Weekly+Xamarin&utm_medium=email&utm_source=Weekly_Xamarin_166.
I extended the converter a bit and remove some bugs. It now also converts bold and italic tags as well as br and p-tag. The problem I run into is that when there are multiple links the click gesture does not work. It only works when there is 1 link.
using System; using System.Collections.Generic; using System.Globalization; using System.Text.RegularExpressions; using System.Windows.Input; using Xamarin.Forms; namespace LuisterrijkApp { public class HtmlLabelConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Label label = null; // label is used to set the FontSize for Bold and Italic if (parameter is Label) { label = (Label)parameter; } var formatted = new FormattedString(); foreach (var item in ProcessString((string)value)) { if (item.Type == "b") { formatted.Spans.Add(CreateBoldSpan(item, label)); } else if (item.Type == "i") { formatted.Spans.Add(CreateItalicSpan(item, label)); } else { formatted.Spans.Add(CreateAnchorSpan(item)); } } return formatted; } private Span CreateAnchorSpan(StringSection section) { var span = new Span() { Text = section.Text }; if (!string.IsNullOrEmpty(section.Link)) { span.GestureRecognizers.Add(new TapGestureRecognizer() { Command = _navigationCommand, CommandParameter = section.Link }); span.TextColor = Color.Blue; // Underline coming soon from https://github.com/xamarin/Xamarin.Forms/pull/2221 // Currently available in Nightly builds if you wanted to try, it does work :) // As of 2018-07-22. But not avail in 3.2.0-pre1. // span.TextDecorations = TextDecorations.Underline; } return span; } private Span CreateBoldSpan(StringSection section, Label label) { var span = new Span() { Text = section.Text, FontAttributes = FontAttributes.Bold }; if (label != null) { span.FontSize = label.FontSize; } return span; } private Span CreateItalicSpan(StringSection section, Label label) { var span = new Span() { Text = section.Text, FontAttributes = FontAttributes.Italic }; if (label != null) { span.FontSize = label.FontSize; } return span; } public IList<StringSection> ProcessString(string rawText) { rawText = rawText.Replace("<br>", "\n"); rawText = rawText.Replace("<br/>", "\n"); rawText = rawText.Replace("<br />", "\n"); rawText = rawText.Replace("<p>", "\n"); rawText = rawText.Replace("</p>", "\n"); const string spanPattern = @"(<[abi].*?>.*?</[abi]>)"; MatchCollection collection = Regex.Matches(rawText, spanPattern, RegexOptions.Singleline); var sections = new List<StringSection>(); var lastIndex = 0; foreach (Match item in collection) { var foundText = item.Value; sections.Add(new StringSection() { Text = rawText.Substring(lastIndex, item.Index - lastIndex) }); lastIndex = item.Index + item.Length; var html = new StringSection() { Link = Regex.Match(item.Value, "(?<=href=\\\")[\\S]+(?=\\\")").Value, Text = Regex.Replace(item.Value, "<.*?>", string.Empty), Type = item.Value.Substring(1,1) }; sections.Add(html); } sections.Add(new StringSection() { Text = rawText.Substring(lastIndex) }); return sections; } public class StringSection { public string Text { get; set; } public string Link { get; set; } public string Type { get; set; } } private ICommand _navigationCommand = new Command<string>((url) => { Device.OpenUri(new Uri(url)); }); public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }}