Label wrapping with StackLayout

I use Xamarin and create my own view using XAML, and I canโ€™t get this shortcut for life so that it turns around the way I want it. If the shortcut hits the edge of the screen, I want to wrap this ...

So I want it to look

Now it looks like this:

This is how it appears

Here is my code:

<StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand" BindingContext="{Binding CurrentProviderDetails}" Padding="20,20,20,20" > <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <!--Certification Board--> <StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand" Grid.Row="0" Grid.Column="0" > <Label Text="Certification Board: " FontSize="13" HorizontalOptions="Fill" VerticalOptions="CenterAndExpand" /> <Label Text="{Binding Certification}" VerticalOptions="CenterAndExpand" HorizontalOptions="Center" Font="17" LineBreakMode="WordWrap"/> </StackLayout> </Grid> </StackLayout> 

It does not have to be in the grid, it was only the method that I tried now. My only requirement is the โ€œCertification Boardโ€ - this is a label, and I need to convey the meaning that the word carries when it reaches the end of the screen. Any help would be awesome, thanks!

+7
xaml label xamarin textwrapping
source share
2 answers

Put the LineBreakMode = "NoWrap" tag in your tags. This way you can avoid wrapping.

But if you do not have enough space, the word will be shortened.

+4
source share

You can achieve the desired result by combining both etiquettes contained in the horizontal alignment of StackLayout into a single label and set LineBreakMode = "WordWrap". XAML has a great feature known as StringFormat. You can use this to add the static text "Certification Commission:" to the associated certification property. Your shortcut should look like this:

 <Label Text="{Binding Certification, StringFormat='Board Certification:{0:F0}'}" LineBreakMode="WordWrap"/> 
0
source share

All Articles