dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.01k stars 1.72k forks source link

Label FormattedText fails to display html text when populated via binding #19867

Open Emanuele9xx opened 8 months ago

Emanuele9xx commented 8 months ago

Description

When setting the FormattedText property of a Label control to content with simple html tags, the control display different content base on the way the FormattedText proeprty is set. When Text is set in Xaml, the label displays formatted text as expected. When Text is set via binding, the label displays text without formatting, with the html tags visible.

Expected: when using binding to populate text, the label should display html formatted content.

Steps to Reproduce

Screenshot 2024-01-12 alle 16 45 51

Xaml without binding (ok):

<img width="453" alt="image" src="https://github.com/dotnet/maui/assets/152969323/33c6225c-a1f2-430d-afa0-24680da02f67">

Xaml with binding (ko):

<Label
                FormattedText="{Binding MyString}"
                FontSize="21"/>

Code for binding:

<img width="577" alt="image" src="https://github.com/dotnet/maui/assets/152969323/6d2d2332-089d-44fd-8d39-f2f36e64f407">

Link to public reproduction project repository

No response

Version with bug

8.0.5

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

ios 17.2

Did you find any workaround?

No response

Relevant log output

No response

Emanuele9xx commented 8 months ago

Similar to bug #13015

ghost commented 8 months ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

boris-sclauzero-zupit commented 8 months ago

Same problem for me ! solved using something like this:

FormattedText = new FormattedString
        {
            Spans = {
               new Span { Text = "Binding: ", TextColor = Colors.Red },
               new Span { Text = "\u003e", TextColor = Colors.Blue }
            }
        };

To get the correct encoding of the character I used: IconFont2Code