Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Bug or wrong approach? FormattedText and Bindings through XAML throw an exception

$
0
0

We have a Label that has a sentence as the Text property, we want to split it in two to style it differently.
The original approach that compiles and "works" but doesn't show up on screen because our view only allows one component.

<Label Text="{Binding Info}"
      TextColor="#666666"
      FontSize="Small" />
<Label Text="{Binding Sum}"
    TextColor="#666666"
    Font="Bold"
    FontSize="Small" />

When we tried this, it throws an exception. Without the Binding, it works.

<Label>
    <Label.FormattedText>
        <FormattedString>
            <FormattedString.Spans>
                <Span Text="{Binding Info}" ForegroundColor="Red" FontAttributes="Italic" FontSize="10" />
                <Span Text="{Binding Sum}" ForegroundColor="Blue" FontSize="10" />
            </FormattedString.Spans>
        </FormattedString>
    </Label.FormattedText>
</Label>

Does anyone think this is a bug, or it's usually done another way?


Viewing all articles
Browse latest Browse all 89864

Trending Articles