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

Label LineBreakMode WordWrap behaves as CharacterWrap when using Bindings

$
0
0

I have a Label in which the Text or FormattedText property is populated with a binding towards a property on my ViewModel. The LineBreakMode has been set to WordWrap, but it behaves as a CharacterWrap. Replacing the LineBreakMode with Head/Middle/TailTruncation or NoWrap works as expected. When the binding is replaced by just a long text without a binding, then it also works as expected.

<!-- Working without binding -->
<Label
    HorizontalOptions="Fill" VerticalOptions="Center"
    YAlign="Center"
    LineBreakMode="WordWrap"
    FontSize="12"
    Text="This is a very long text that should be put over multiple lines to ensure that no characterwrap occurs, but that wordwrap does."/>

<!-- NOT working with binding -->
<Label
    HorizontalOptions="Fill" VerticalOptions="Center"
    YAlign="Center"
    LineBreakMode="WordWrap"
    FontSize="12"
    Text="{Binding LongText}"/>

<!-- Desired situation - NOT working with binding -->
<Label
    HorizontalOptions="Fill" VerticalOptions="Center"
    YAlign="Center"
    LineBreakMode="WordWrap"
    FontSize="12"
    FormattedText="{Binding LongText, Converter={StaticResource FormattedStringValueConverter}}"/>

As context, I'm using this inside a StackLayout within a ViewCell that is shown inside a ListView, but that doesn't seem to effect this case.
This occurs on iOS, haven't been able to try it on Android yet...

I'm on Xamarin.Forms 1.5.1.6471


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>