Hi all,
I'm facing a problem with ListView (Xamarin.Forms):
In page 1, I try to open page 2, and then load data:
Page2 page2 = new Page2 (mCurrentActivityType);
if (Device.OS != TargetPlatform.iOS) {
await MainPage.GetInstance().Navigation.PushModalAsync(page2);
} else {
await MainPage.GetInstance().Navigation.PushAsync(page2);
}
Page2ViewModel)productSelectionPage.BindingContext).LoadData();
My LoadData function:
public void LoadData()
{
ListViewData = new ObservableCollection(mBusinessLogic.GetData());
}
After I execute this code, the ListView show nothing (it seems not refresh). I already called the OnPropertyChanged for ListViewData but the list is still empty until I click on any buttons in screen and the application has crashed.
I even tried:
Xamarin.Forms.Device.BeginInvokeOnMainThread(new Action(((Page2ViewModel)page2.BindingContext).LoadData));
But the same problem still occurs.
I notice that when I call the LoadData() in constructor of Page2 every thing going well.
Could you guys please help me on this?
Thanks in advanced.