0
我正在創建一個財務應用程序,需要顯示一個帶有節標題和許多網格的表格。Xamarin表格網格在一個TableView中
在附上的截圖中,我幾乎在那裏。我需要第一列左對齊(開始)和行是他們的默認高度的兩倍左右。
var content = new TableView
{
Intent = TableIntent.Data,
Root = new TableRoot("Performance"),
BackgroundColor = Color.Green
};
content.Root.Add(GetTableSection("Monthly", Model.Monthly);
.................
private TableSection GetTableSection(string title, List<PerformanceRow> performanceRows)
{
TableSection section = new TableSection()
{
Title = title
};
foreach (var row in performanceRows)
{
Grid grid = new Grid
{
VerticalOptions = LayoutOptions.FillAndExpand,
HeightRequest = 100, //?????????
BackgroundColor = Color.Red,
ColumnDefinitions =
{
new ColumnDefinition {Width = new GridLength(.3, GridUnitType.Star)},
new ColumnDefinition {Width = new GridLength(.3, GridUnitType.Star)},
new ColumnDefinition {Width = new GridLength(.3, GridUnitType.Star)},
}
};
//First Row
grid.Children.Add(new Label {Text = row.Title, HorizontalOptions = LayoutOptions.Start}, 1, 0);
grid.Children.Add(new Label {Text = "Market Value"}, 2, 0);
grid.Children.Add(new Label {Text = row.MarketValue.ToString("C"), HorizontalOptions = LayoutOptions.End}, 3, 0);
//Second Row
grid.Children.Add(new Label {Text = " "}, 1, 1);
grid.Children.Add(new Label {Text = "Return"}, 2, 1);
grid.Children.Add(new Label {Text = row.ReturnRate.ToString("C"), HorizontalOptions = LayoutOptions.End}, 3, 1);
section.Add(new ViewCell()
{
View = grid,
Height = 100 //??????????
});
}
return section;
}