我正尝试在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类构造函数中检索ClassId时遇到了问题,有没有其他方法可以获得我想要的输出?
public Sales()
{
InitializeComponent();
BindingContext = this;
salesCollection = new ObservableCollection<Head>();
initLvw();
Console.WriteLine(Title); //returns null
Console.WriteLine(ClassId); // returns null
}发布于 2020-05-19 13:27:11
您可以在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();
});
}https://stackoverflow.com/questions/61882947
复制相似问题