Hi, can anyone help me on matter as below ?
I unable to wordwrap nicely a label within a grid cell ?
Grid grid = new Grid
{
VerticalOptions = LayoutOptions.FillAndExpand,
RowDefinitions =
{
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto }
},
ColumnDefinitions =
{
new ColumnDefinition { Width = GridLength.Auto },
new ColumnDefinition { Width = GridLength.Auto }
}
};
Func<string, Label> CreateLabelWordWrap = (string source) =>
{
Label label = new Label
{
FontSize = 20,
FontAttributes = Xamarin.Forms.FontAttributes.Bold,
XAlign = TextAlignment.Start,
LineBreakMode = LineBreakMode.WordWrap,
HorizontalOptions = LayoutOptions.Fill
};
label.SizeChanged += label_SizeChanged;
label.SetBinding(Label.TextProperty, source);
return label;
};
void label_SizeChanged(object sender, EventArgs e)
{
Label lb = ((Label)sender);
lb.WidthRequest = lb.Text.Length;
}
It will keep appear extra empty space between next Row (as image show in attached file).
How should I improve it ?