1
我在Xamarin表单应用中有一个列表视图,我的一个标签可以有一个非常长的一组文本。问题在于文本被切断,标签的高度从来没有多线。没有在列表视图中设置单元格高度
我可以多行吗? 我可以让身高更高吗?
以下是我的代码。我尝试过在几个地方调整高度,但没有一个让这个单元变大。
// each item; it must return a Cell derivative.)
ItemTemplate = new DataTemplate(() =>
{
// Create views with bindings for displaying each property.
Xamarin.Forms.Label nameLabel = new Xamarin.Forms.Label();
nameLabel.SetBinding(Xamarin.Forms.Label.TextProperty,
new Binding("Name", BindingMode.OneWay,
null, null, "{0}"));
Xamarin.Forms.Label yearLabel = new Xamarin.Forms.Label();
yearLabel.SetBinding(Xamarin.Forms.Label.TextProperty,
new Binding("Birthday", BindingMode.OneWay,
null, null, "FMI {0:yyyy}"));
Xamarin.Forms.Label componentLabel = new Xamarin.Forms.Label();
componentLabel.SetBinding(Xamarin.Forms.Label.TextProperty,
new Binding("Component", BindingMode.OneWay,
null, null, "Component: {0}"));
Xamarin.Forms.Label descriptionLabel = new Xamarin.Forms.Label();
descriptionLabel.SetBinding(Xamarin.Forms.Label.TextProperty,
new Binding("Description", BindingMode.OneWay,
null, null, "{0}"));
descriptionLabel.HorizontalOptions = LayoutOptions.FillAndExpand;
descriptionLabel.LineBreakMode = LineBreakMode.NoWrap;
descriptionLabel.HeightRequest = 256.0;
descriptionLabel.MinimumHeightRequest = 250.0;
BoxView boxView = new BoxView();
boxView.SetBinding(BoxView.ColorProperty, "SeverityColor");
boxView.MinimumHeightRequest = 100.0;
boxView.MinimumHeightRequest = 100.0;
// Return an assembled ViewCell.
return new ViewCell
{
View = new StackLayout
{
Padding = new Thickness(0, 2),
Orientation = StackOrientation.Horizontal,
HeightRequest = 155.0,
MinimumHeightRequest = 155.0,
Children =
{
boxView,
new StackLayout
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Fill,
Spacing = 0,
HeightRequest = 235.0,
MinimumHeightRequest = 250.0,
Children =
{
componentLabel,
descriptionLabel
}
}
}
},Height = 250
};
})
这就是我需要的。我的行都太大,但是需要该属性来履行行高请求。谢谢 – Maestro1024