Xamarin 动态标签页

Xamarin dynamic tabbed page

我正在努力实现以下目标:

现在,如果我像这样使用它 hard-coded,它就可以正常工作了:

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="WunderlistApp.View.MainPage"
            NavigationPage.HasNavigationBar="False">
    <!--Pages can be added as references or inline-->
    <ContentPage Title="RallyPodium &amp; Reporting" />
    <ContentPage Title="Projecten voor klanten" />
    <ContentPage Title="School" />
</TabbedPage>

现在我想做的是制作这些标签 "dynamically"。我的意思是,我想 "link" API 的标题(数据可从 .cs 文件绑定)到 xaml 文件(或用 C# 制作) ,但我不知道怎么做)。然后内容必须以某种方式从中出现(它基本上只是一个列表视图)...

如果有人能帮我解决这个问题?

这是.cs代码:

public MainPage()
        {
            InitializeComponent();
            //GetFolders();
        }

        private async Task GetFolders()
        {
            List<Folder> folders = await ApiManager.GetFoldersAsync();

            //foreach (Folder f in folders)
            //{
            //    Debug.WriteLine("Folder name: {0}", f.title);
            //}

            //lvwMainTasksList.ItemsSource = folders;
        }

我也不知道如何 link 一个 contentPage 到标签页?

foreach (var f in folders) {
  // if you are in code-behind of a TabbedPage, "this" will be TabbedPage
  this.Children.Add(new ContentPage { Title = f });
}