使用StackLayout进行标签包装 [英] Label wrapping with StackLayout

查看:165
本文介绍了使用StackLayout进行标签包装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xamarin并使用XAML创建视图,我一生都无法获得此标签来包装我想要的方式.如果标签到达屏幕边缘,我希望它像这样包裹起来...

I'm using Xamarin and creating my view with XAML and I cannot for the life of me get this label to wrap the way I want it to. If the label gets to the edge of the screen, I want it to wrap like this...

现在看起来像这样...

Right now it is looking like this...

这是我的代码:

<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>

这不需要在网格中;这只是我现在正在尝试的方法.我唯一的要求是"Certification Board"是一个标签,当到达屏幕末尾时,我必须传递一个自动换行的值.任何帮助都会很棒,谢谢!

This doesn't need to be in a grid; this was just the method I was trying for now. My only requirement is that 'Certification Board' is a label, and I have to pass in a value that word wraps when it gets to the end of the screen. Any help would be awesome, Thanks!

推荐答案

在标签中放置LineBreakMode ="NoWrap"标签.这样一来,您就可以避免自动换行了.

Put a LineBreakMode="NoWrap" tag in your labels. This way you can avoid the wrap.

但是如果您没有足够的空间,该单词将被剪切掉.

But if you don't have enough space, the word will be cut.

这篇关于使用StackLayout进行标签包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆