我可以在 tabbedpage 中使用 ClassId 来区分它们的内容吗

Can I use ClassId in tabbedpage to differentiate their content

我正在尝试对 TabbedPage 中的 3 个选项卡使用同一页面。但是每个选项卡必须在列表视图中显示不同的数据。有没有办法为每个选项卡设置一个参数?

例子

    <local:Sales Title="Pending" 
                 Icon="ic_shortcut_home.png"
                 ClassId="pending"/>

    <local:Sales Title="Posted" 
                 Icon="ic_shortcut_home.png"
                 ClassId="posted"/>

    <local:Sales Title="Uploaded" 
                 Icon="ic_shortcut_home.png"
                 ClassId="uploaded"/> 

我尝试使用 ClassId 和 Title 来区分它们,但我在 Sales class 构造函数中检索 ClassId 时遇到问题,是否有任何其他方法可以获得我想要的输出?

        public Sales()
        {
            InitializeComponent();
            BindingContext = this;
            salesCollection = new ObservableCollection<Head>();
            initLvw();
            Console.WriteLine(Title); //returns null
            Console.WriteLine(ClassId); // returns null
        }

您可以在OnAppearing方法中加载数据:

protected override void OnAppearing()
{
    base.OnAppearing();

    Console.WriteLine(ClassId + "OnAppearing");

    BindingContext = this;
    salesCollection = new ObservableCollection<Head>();
    initLvw();

}

或者在构造函数中用一点delay加载数据:

public AboutPage()
{
    InitializeComponent();

    Task.Run(async () =>
    {
        await Task.Delay(200);
        Console.WriteLine(ClassId + "AboutPage");

        BindingContext = this;
        salesCollection = new ObservableCollection<Head>();
        initLvw();
    });
}