Reputation: 4328
I have a Label
inside a Grid
. I want:
Grid
and the Label
to be as small as possible.Label
should use up to two lines if necessary.This is what I have:
<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>
And this is how it looks:
Upvotes: 1
Views: 930
Reputation: 10156
In conclusion, this is a known issue that be tracked in this thread:https://github.com/dotnet/maui/issues/10494. As @Shaw suggested, we can replace the Grid
with an StackLayout
to fix the issue. I'll keep an eye on the thread until this is being totally solved.
Thanks for your feedback and patience!
Upvotes: 1