Label().LoadFromXaml does not work when using Label.FormattedText
roughiain opened this issue · 1 comments
roughiain commented
Description
When using
var label = new Label().LoadFromXaml(xaml);
if the string contains formatted text it is ignored
/// <summary>
/// Taken from https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/label#use-formatted-text with the guesture recognizer removed.
/// </summary>
private static string xaml = """
<Label LineBreakMode="WordWrap">
<Label.FormattedText>
<FormattedString>
<Span Text="Red Bold, " TextColor="Red" FontAttributes="Bold" />
<Span Text="default, " FontSize="14"/>
<Span Text="italic small." FontAttributes="Italic" FontSize="12" />
</FormattedString>
</Label.FormattedText>
</Label>
""";
Full code
/// <summary>
/// Taken from https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/label#use-formatted-text with the guesture recognizer removed.
/// </summary>
private static string xaml = """
<Label LineBreakMode="WordWrap">
<Label.FormattedText>
<FormattedString>
<Span Text="Red Bold, " TextColor="Red" FontAttributes="Bold" />
<Span Text="default, " FontSize="14"/>
<Span Text="italic small." FontAttributes="Italic" FontSize="12" />
</FormattedString>
</Label.FormattedText>
</Label>
""";
public MainPage()
{
InitializeComponent();
var label = new Label().LoadFromXaml(xaml);
if (label.FormattedText is null)
{
throw new Exception("This does not work");
}
TheVerticalStackLayout.Children.Add(label);
}
Repo: https://github.com/roughiain/CanILoadFormttedTextInLoadFromXaml
Steps to Reproduce
clone and run
Link to public reproduction project repository
https://github.com/roughiain/CanILoadFormttedTextInLoadFromXaml
Version with bug
7.0.92
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android
Affected platform versions
All platforms including Xamarin
Did you find any workaround?
No
Relevant log output
No response
msftbot commented
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.