Bindable Span

ChaseFlorellChaseFlorell CAInsider, University mod
edited May 2017 in Xamarin.Forms Evolution

Summary

The Span class should have Bindable properties and the addition of a Style property.

API Changes

Make Span Inherit from BindableObject and support bindings on the properties. Also add a Style property so that Spans can be individually styled in the same way as a Label.

eg:

<Label>
    <Label.FormattedText>
        <FormattedString>
            <FormattedString.Spans>
                <Span Text="My Label" Style="{StaticResource title-style}" />
                <Span Text="{Binding Info}" Style="{StaticResource text-style}" />
                <Span Text="{Binding Sum}" Style="{StaticResource number-style}" />
            </FormattedString.Spans>
        </FormattedString>
    </Label.FormattedText>
</Label>

Intended Use Case

Bindable spans make for much simpler FormattedText. This is not the first time this has been requested.
https://xamarin.uservoice.com/forums/258559-xamarin-forms-suggestions/suggestions/6256703-extend-span-with-bindable-text-and-tapgesture
https://xamarin.uservoice.com/forums/258559-xamarin-forms-suggestions/suggestions/6622199-unseal-span-or-make-it-bindable

Also nice to have the ability to nicely format labels as follows.

SPANS-FTW

0
0 votes

Completed · Last Updated

Posts

Sign In or Register to comment.