如何让Grid内的Label最小化且最多显示两行?
Grid内嵌Label的布局需求及当前实现
需求
- Grid与Label的尺寸尽可能小
- Label必要时最多显示两行
当前实现代码
<VerticalStackLayout Spacing="8"> <Label Text='With HorizontalOptions="Start":' /> <Grid BackgroundColor="#FCC" HorizontalOptions="Start"> <Label Text="This will not wrap." MaxLines="2" /> </Grid> <Grid BackgroundColor="#FCC" HorizontalOptions="Start"> <Label Text="This will not wrap. This will not wrap. This will not wrap. This will not wrap. This will not wrap. This will not wrap. This will not wrap. This will not wrap. " MaxLines="2" /> </Grid> <Label Text='With HorizontalOptions="Fill":' /> <Grid BackgroundColor="#CFC" HorizontalOptions="Fill"> <Label Text="This wraps, but fills." MaxLines="2" /> </Grid> <Grid BackgroundColor="#CFC" HorizontalOptions="Fill"> <Label Text="This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills. This wraps, but fills." MaxLines="2" /> </Grid> </VerticalStackLayout>
当前效果

内容的提问来源于stack exchange,提问作者PEK
相关产品推荐
相关产品推荐

