简体   繁体   中英

Create TableView in Xamarin C# Visual Studio

Refer to the code below, may I know what does it mean ... When I copy to my xml project of visual studio, it is error.

Content = new TableView {
    Root = new TableRoot {
        new TableSection...
    },
    Intent = TableIntent.Settings
};

I'm assuming you are replicating the Example in Xamarin Page. The errors you are facing, is that you are not creating the ViewCell for the TableView.

Here is a working example that should get you started.

var table = new TableView();
table.Intent = TableIntent.Settings;
var layout = new StackLayout() { Orientation = StackOrientation.Horizontal };
layout.Children.Add (new Label() {
    Text = "TestLayout",
    TextColor = Color.FromHex("#f35e20"),
    VerticalOptions = LayoutOptions.Center
});

table.Root = new TableRoot () {
    new TableSection("Getting Started") {
        new ViewCell() {View = layout}
    }
};

Content = table;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM