I'm using a Label with Spans, one of them is a link and I want to add an underline style, I'm using <Span Text="Link url" TextDecorations="Underline" /> but it is not working in iOS with "Xamarin.Forms" Version="5.0.0.2401".
I have tried to add an effect but all the properties needs to be set again (Styles, touch events, etc...).
<Label>
<Label.FormattedText>
<FormattedString>
<Span Text="Text 1"/>
<Span Text="Text 2"/>
<Span Text="Click to open Link" TextDecorations="Underline">
<Span.GestureRecognizers>
<TapGestureRecognizer Command="{Binding lINKCommand}"/>
</Span.GestureRecognizers>
</Span>
</FormattedString>
</Label.FormattedText>
</Label>
In some time Xamarin forms needs to fix it, meanwhile I want to apply a small temporal fix.
I discovered that it works when set TextType property to Html in the Label at runtime.
So I had to create a data trigger and use a data binding to set when all data is loaded.
<Label>
<Label.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding IsBusy}" Value="false">
<Setter Property="TextType" Value="Html" />
</DataTrigger>
</Label.Triggers>
<Label.FormattedText>
<FormattedString>
<Span Text="Text 1"/>
<Span Text="Text 2"/>
<Span Text="Click to open Link" TextDecorations="Underline">
<Span.GestureRecognizers>
<TapGestureRecognizer Command="{Binding lINKCommand}"/>
</Span.GestureRecognizers>
</Span>
</FormattedString>
</Label.FormattedText>
</Label>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With