【问题标题】:Xamarin Forms - Html2Xaml converter issue with span TapGestureRecognizer commandXamarin Forms - 使用 span TapGestureRecognizer 命令的 Html2Xaml 转换器问题
【发布时间】:2020-03-04 07:13:18
【问题描述】:

我正在尝试将 FormattedString xaml 中的自定义 html 文本转换为任何标签。在那里,我有一个 <a/> 标记,它将使用 TapGestureRecognizer 转换为跨度:

<xsl:template match="A | a" priority="9">
    <Span TextDecorations="Underline">
        <xsl:attribute name="Text">
            <xsl:apply-templates />
        </xsl:attribute>
        <Span.GestureRecognizers>
            <TapGestureRecognizer Command="{{Binding PopupContentCommand}}">
                <xsl:attribute name="CommandParameter">
                    <xsl:value-of select="@href" />
                </xsl:attribute>
            </TapGestureRecognizer>
        </Span.GestureRecognizers>
    </Span>
</xsl:template>

转换器运行良好,问题是此命令绑定没有引发。当我们将 new FormattedString().LoadFromXaml(xaml) 转换后的 html 加载到 xaml 时,该命令似乎具有绑定:

但是这个绑定没有提升。之后,我尝试清除 GestureRecognizers 并创建一个新的 TapGestureRecognizer 再次添加它。但这也不起作用。 BindingContext 似乎也是正确的。

这是通过绑定附加属性来完成的:

<Label attachedProperties:Properties.Html="{Binding HtmlText}" />

【问题讨论】:

    标签: xaml xamarin xslt xamarin.forms


    【解决方案1】:

    最后是模拟器问题。因为在真实设备中,这没有问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-03
      • 2017-11-12
      • 2022-01-15
      • 2021-12-06
      • 1970-01-01
      • 2021-07-29
      • 2020-01-15
      • 1970-01-01
      相关资源
      最近更新 更多