我正在尝试将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>
转换器运行良好,问题在于此命令绑定没有提高。当我们将转换后的html加载new FormattedString().LoadFromXaml(xaml)
到xaml时,该命令似乎具有绑定:
但是这种约束力没有提高。之后,我尝试清除GestureRecognizers并创建一个新的TapGestureRecognizer并再次添加它。但这也不起作用。 BindingContext似乎也是正确的。
这是通过绑定附加属性来完成的:
<Label attachedProperties:Properties.Html="{Binding HtmlText}" />
最后是模拟器问题。因为在实际设备中,这毫无疑问会上升。