G'day all. I have some code that creates children of a Carousel page based on information coming back from a service request. The following code works when on iOS but not on Android. I have the carousel page declared at a class level filling it up in a AsyncTask method and then calling it as a return parameter in a Page. Even without the Wait method with the arbitrary 1000ms applied it works in iOS, i just added it so see if it would aid in debugging.
the calling method is a button click that does this.
meetTeamButton.Clicked += (sender, e) => {
// var j = new JBTeamAppV2();
// var p = j.GetTeamMembers();
// j.RefreshAsync().Wait(1000);
Navigation.PushAsync(new JBTeamAppV2().GetTeamMembers());
//Navigation.PushAsync(p);
//Console.WriteLine("test");
};
I Appreciate any thoughts
`namespace jbb
{
public class JBTeamAppV2 : Application
{
BeerListViewViewModel staffSvc = new BeerListViewViewModel();
CarouselPage mcp = new CarouselPage();
public async Task RefreshAsync()
{
var currStaff = await staffSvc.GetAllStaffAsync();
mcp.Title = "Our Team";
mcp.Icon = "Contacts-30.png";
foreach (var s in currStaff.staffs) {
var jbt = new JBTeam () {
Name = s.Name,
Title = s.Title,
Desc = s.Desc,
PicURL = s.PicURL
};
mcp.Children.Add (new MeetOurFolks(jbt));
}
// var x = mcp.Children.Count ().ToString ();
//this will return the right value of 19 items
// Console.WriteLine (x);
}
public Page GetTeamMembers ()
{
RefreshAsync().Wait(1000);
// var y = mcp.Children.Count ().ToString ();
//this will return zero
// Console.WriteLine (y);
return mcp;
}
}
}
`