【发布时间】:2019-11-15 16:27:56
【问题描述】:
将本地 HTML 代码直接显示到我的 page.xaml.cs 文件中的最佳方式是什么?我想将 html 代码直接写入 .cs 文件。谢谢
我将在我的 page.xaml.cs 中使用它
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;
但是在 xaml 文件中,我如何显示这个 html 并将其放入堆栈布局中?
【问题讨论】:
-
但是 .cs 文件只是一个文本文件,编译器将其转换为程序的类。所以你唯一能做的就是使用多行注释
-
@DudeWhoWantsToLearn 我想在 page.xaml 中显示 HTML 代码
-
@MassimoAusiello 使用 Web 视图:docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/…
-
@DudeWhoWantsToLearn 嗨更新了我的答案