Forum Xamarin.Forms

Table View in Xamarin - Forms

How to display list data into table view in Xamarin.forms?



  • JarvanJarvan Member, Xamarin Team Xamurai

    TableView does not have the concept of an ItemsSource, so items must be manually added as children. You can add data to the TableView by traversing the list. Refer to the code:

    public partial class Page2 : ContentPage
        ObservableCollection<_model> list = new ObservableCollection<_model>();
        public Page2()
            list.Add(new _model { content = "label_1" });
            list.Add(new _model { content = "button_2" });
            foreach (var item in list)
                layout.Children.Add(new Label() { Text = item.content, HorizontalOptions = LayoutOptions.CenterAndExpand });


            <TableSection x:Name="section">
                    <StackLayout x:Name="layout" Orientation="Vertical">
  • JoeMankeJoeManke USMember ✭✭✭✭✭

    Or just use a ListView...

Sign In or Register to comment.