How can I show text with html format in xamarin forms
This should work for you
string htmlText = MyItem.Article.ToString().Replace(@"\", string.Empty);
var browser = new WebView ();
var html = new HtmlWebViewSource {
Html = htmlText
};
browser.Source = html;
Because Xamarin.Forms.HtmlWebViewSource.HTML
expect a pure HTML. Using this you can create a Xamarin.Forms user control with the help of this article http://blog.falafel.com/creating-reusable-xaml-user-controls-xamarin-forms/ Cheers..!
In XAML you can do something like this:
<WebView>
<WebView.Source>
<HtmlWebViewSource Html="{Binding HtmlText}"/>
</WebView.Source>
</WebView>
You may also need to provide Height and Width of the WebView
if it's not inside a Grid
.