Xamarin Forms control where I can show HTML formated text

夙愿已清 提交于 2019-12-08 14:43:19

问题


I'm new in Xamarin and I try to show a HTML text in a Xamarin Form control.

For example, if I have the following HTML text:

<ul>
<li>First</li>
<li>Second</li></ul>

It should show the following result in the Xamarin app:

  • First
  • Second

Is there a control for that?

Thanks for any help.


回答1:


WebView:

You can use WebView to open an local HTML file to display it.

webviewjava.BaseUrl = DependencyService.Get<IBaseUrl>().Get();
webviewjava.Source = "index.html";

**** index.html is your local HTML file.*

HtmlWebViewSource: Or If you want to present a string of HTML defined dynamically in code, you'll need to create an instance of HtmlWebViewSource:

var browser = new WebView();
var htmlSource = new HtmlWebViewSource();
htmlSource.Html = @"<html><body>
  <h1>Xamarin.Forms</h1>
  <p>Welcome to WebView.</p>
  </body></html>";
browser.Source = htmlSource;



来源:https://stackoverflow.com/questions/47776370/xamarin-forms-control-where-i-can-show-html-formated-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!