【发布时间】: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