【问题标题】:display html formatted data xamarin forms显示 html 格式的数据 xamarin 表单
【发布时间】:2018-05-29 13:48:00
【问题描述】:

我正在使用 webview 来显示来自数据库的 html 格式的数据。我已经尝试实现 HtmlWebViewSource 来显示数据,但它没有显示。这是我已经实现的。

<WebView VerticalOptions="Fill" BackgroundColor="Red">
                    <WebView.Source>
                        <HtmlWebViewSource x:Name="surveyInstruction"/>
                    </WebView.Source>
                </WebView>

.cs

surveyInstruction.Html = result[1][i].vchar_Instruction;

这是我从数据库中得到的

Question<font size="4"><b> Instruction</b></font>

我也提到了这篇文章 Xamarin Forms control where I can show HTML formated text

【问题讨论】:

    标签: webview xamarin.forms


    【解决方案1】:

    您使用的是哪个版本的 Xamarin.Forms?我记得有一些问题,比如this one。

    我正在使用 WebView 如下(带绑定),这对我来说很好。

        <WebView
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand">
            <WebView.Source>
                <HtmlWebViewSource Html="{Binding PrivacyPolicyAsHtml}" />
            </WebView.Source>
        </WebView>
    

    PrivacyPolicyAsHtml 属性存在于视图模型中并被分配在那里。

    【讨论】:

      【解决方案2】:

      将 VerticalOptions 从“Fill”更改为“FillAndExpand”,您应该可以看到 WebView 或根据要求设置 WebView 的高度。

      【讨论】:

        猜你喜欢
        • 2016-02-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-10-28
        • 2013-10-28
        • 1970-01-01
        相关资源
        最近更新 更多