Hi I am using Xamarin Forms with firebase, I am trying to populate a listview in the view "NavigationListCardPage"
The listview Binding is NavigationList (ItemsSource="{Binding NavigationList}"), which is an ObservableCollection<NavigationModel>
in the file: NavigationListCardPage.xaml.cs
public NavigationListCardPage(int Rol)
{
this.InitializeComponent();
Task.Run(async () =>
{
this.BindingContext = await myownDataFireBaseCards("1", 1);
});
//this.BindingContext =
//NavigationDataService.Instance.NavigationViewModel;
}
private async Task<NavigationViewModel> myownDataFireBaseCards(string IDperson, int Rol)
{
FirebaseClient firebaseClient = new FirebaseClient(MyGlobal.RealDataBaseURL);
var allCasas = await firebaseClient.Child("Prueba").OnceAsync<Models.NavigationModel>();
NavigationViewModel navigationViewModel;
var Devolver = new ObservableCollection<Models.NavigationModel>();
foreach (var Casa in allCasas)
{
Devolver.Add(new Models.NavigationModel
{
ItemDescription = Casa.Object.ItemDescription,
ItemImage = "Recipe19.png", // Casa.Object.ItemImage,
ItemName = Casa.Object.ItemName,
ItemRating = Casa.Object.ItemRating,
});
}
var Retorname = new NavigationViewModel { NavigationList = Devolver };
return Retorname;
}
I check and "Retorname" is indeed an ObservableCollection<NavigationModel> with two objects, but I do not know why ListView is empty
What can I do to this works?