xaml - Xamarin - HtmlWebViewSource 和 XAML

标签 xaml xamarin.forms

我尝试从 WebView 控件内部的模型显示 HTML。经过一番谷歌搜索后,我意识到我无法使用 Source 属性,因为它只能用 URL 或 URI 填充。

经过几次额外的搜索后,我发现了 HtmlWebViewSource,但我找不到通过 XAML 使用 HtmlWebViewSource 的示例。

有谁知道如何在 XAML 中定义 HtmlWebViewSource 实例,从模型绑定(bind) HTML 并将其分配给 WebView

谢谢!

最佳答案

回答我自己

<WebView x:Name="_webView" HorizontalOptions="Fill" VerticalOptions="EndAndExpand">
     <WebView.Source>
         <HtmlWebViewSource
         Html="{Binding HTMLSource}" />
     </WebView.Source>
</WebView>

关于xaml - Xamarin - HtmlWebViewSource 和 XAML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39334576/

相关文章:

c# - 在 C# 中更改网格的 Canvas.ZIndex

c# - WPF 中的 Application.DoEvents() 在哪里?

c# - Xamarin.Forms Navigation.PushAsync 不工作

c# - 如何从 Xamarin.Forms 应用程序修改平台特定属性?

c# - 'MouseEventArgs' 不包含 'GetPosition' 的定义

c# - DataGrid 绑定(bind) - 不显示列表中的空条目

c# - 将 ContentControl *放在 * WPF DataTemplate 中?

xamarin - 在自定义 xamarin 表单 Web View 中设置当前 url

xamarin.forms - ITMS-90809:不推荐使用的API-Apple将停止接受使用UIWebView API的应用程序的提交

c# - Xamarin.Essentials "The current Activity can not be detected. Ensure that you have called Init in your Activity or Application class."