2014-11-24 65 views
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; 
    } 

enter image description here

回答

0

这工作:

设置UnevenRows为true的tableview,那么表意图行

相关问题