2014-11-24 4 views
0

Я создаю финансовое приложение и вам нужно показать таблицу с заголовками разделов и множеством сеток.Xamarin Forms Grid в TableView

В прилагаемом скриншоте я почти там. Мне нужен первый столбец Left align (start), а строки должны быть в два раза меньше их высоты по умолчанию.

 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 истины для Tableview, то намерение таблицы строк