TapGestureRecognizer
不适用于Span Inside标签(FormattedText).Command
没有开火,甚至Tapped
也没有开火.
我在用<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
以下是我的XAML:
<Label LineHeight="1.3" HorizontalTextAlignment="Center">
<Label.FormattedText>
<FormattedString>
<Span Text="Read our " />
<local:HyperlinkSpan Text="Privacy Policy"
Url="https://www.eurycele.com" />
<Span Text=". Tap "Agree and continue" to accept the " />
<local:HyperlinkSpan Text="Terms of Service"
Url="https://www.eurycele.com" />
<Span Text="Terms of Service"
TextColor="Blue">
<Span.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TapCommand}"
CommandParameter="https://learn.microsoft.com/xamarin/" />
</Span.GestureRecognizers>
</Span>
<Span Text="." />
</FormattedString>
</Label.FormattedText>
</Label>
local:HyperlinkSpan
是从https://github.com/xamarin/xamarin-forms-samples/blob/main/UserInterface/Hyperlinks/HyperlinkDemo/HyperlinkSpan.cs减go
我已经try 了以下方法:
- https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/label个
- https://learn.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/userinterface-hyperlinks/个
请提个建议.