在 Xamarin C# Visual Studio 中创建 TableView



>请参考下面的代码,我可以知道它是什么意思...当我复制到我的xml项目时,它是错误的。

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

我假设您正在复制Xamarin页面中的示例。您面临的错误是,您没有为表视图创建视图单元格。

这是一个应该可以帮助您入门的工作示例。

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;

最新更新