Bindable Span

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


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.


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

Intended Use Case

Bindable spans make for much simpler FormattedText. This is not the first time this has been requested.

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


0 votes

Open · Last Updated


  • ChaseFlorellChaseFlorell CAInsider, University mod
    edited May 2017

    As a work around, here's an example of how I have achieved the above.

    <!-- View -->
    <Label FormattedText="{Binding FormattedFoo}" />
    // viewmodel
    public string Foo
        private get { return _foo; }
            if(SetField(ref _foo, value))
    public FormattedString FormattedFoo
            return new FormattedStringBuilder()
                .Span("Foo Label", "My-Title-Style")
                .Span(Foo, "My-Normal-Style")


  • StephaneDelcroixStephaneDelcroix USInsider, Beta ✭✭✭✭

    updating a Span probably means redrawing the full Label on most platform, so this has an hidden performance implication, but I kinda like this proposal.

    could you please develop a bit more on how you plan to support Gestures on Span on the main platforms ?

  • mdizzymdizzy USMember ✭✭

    I have a more generic proposal that might help here. I've been working on graphics primitives as XAML elements. I think Views are expensive but visualelement isn't exposed on the API surface. I've got an idea for how it all works though (proposal coming soon).

  • ChaseFlorellChaseFlorell CAInsider, University mod

    @StephaneDelcroix said:
    could you please develop a bit more on how you plan to support Gestures on Span on the main platforms ?

    I have edited this proposal to remove Gestures. Once I have a better idea on how it would work on the platforms, I will submit as a separate proposal

  • ChaseFlorellChaseFlorell CAInsider, University mod

    @StephaneDelcroix since I've removed the gesture portion of this proposal. What are your thoughts on just introducing the bindable Span?

  • VelocityVelocity NZMember ✭✭✭

    +1. Very useful.

  • +1

  • TobiasSchulz.9796TobiasSchulz.9796 DEMember ✭✭

    Very useful!

  • PradeepSJPradeepSJ USMember ✭✭

    +1 useful

  • AndrewMobileAndrewMobile USMember ✭✭✭✭


  • BobbyTablesBobbyTables GBMember ✭✭


  • NamyslawSzymaniukNamyslawSzymaniuk USMember ✭✭✭

    Would be really useful. +1002

  • wesharpwesharp ITMember ✭✭


  • ChaseFlorellChaseFlorell CAInsider, University mod

    This has been migrated: Cast your +1 on Github

Sign In or Register to comment.