Hi!
I've been stack for a while on a very strange bug. I have a ListView that contains Custom ViewCell, some controls within that ViewCell are populated from database some of them are hardcoded. The amount of cells is depending on the amount of items coming back from the server. This behaves as expected. When I have 6 items coming back from database, ListView renders 6 items, however for some reason last 2, cells are empty.
Here is a code snippet from my XAML and code behind, and screenshot of my application.
<ListView x:Name="usersList" HorizontalOptions="Fill" HasUnevenRows="True" ItemTapped="UserDetailsTapped" RefreshAllowed="true" IsPullToRefreshEnabled="true"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Frame CornerRadius="10" BackgroundColor="White" Margin="0,5,0,5"> <StackLayout Orientation="Vertical" HorizontalOptions="Fill" Margin="-15"> <StackLayout Orientation="Horizontal" Margin="2"> <StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> <StackLayout Orientation="Horizontal" HorizontalOptions="Center"> <Label Text="{Binding Name}" FontSize="Medium" TextColor="#F0BB7F" FontAttributes="Bold" VerticalOptions="Center"/> <Label Text="{Binding Surname}" FontSize="Medium" TextColor="#F0BB7F" FontAttributes="Bold" VerticalOptions="Center"/> </StackLayout> <StackLayout Orientation="Horizontal"> <Label Text="główny przedmiot:" FontSize="Small" TextColor="Gray" VerticalOptions="Center"/> <Label Text="#Matematyka#" FontSize="Small" TextColor="#F0BB7F" VerticalOptions="Center"/> </StackLayout> </StackLayout> <StackLayout HorizontalOptions="EndAndExpand" Margin="2" BackgroundColor="#F0BB7F"> <Image x:Name="ProfileImage" Source="profilwhite"/> </StackLayout> </StackLayout> <StackLayout Orientation="Horizontal" Margin="2"> <Label Text="Cena od" FontSize="Small" TextColor="Gray" VerticalOptions="Center"/> <Label Text="#40#" FontSize="Small" TextColor="#F0BB7F" VerticalOptions="Center"/> <Label Text="do" FontSize="Small" TextColor="Gray" VerticalOptions="Center"/> <Label Text="#60#" FontSize="Small" TextColor="#F0BB7F" VerticalOptions="Center"/> <Label Text="zł" FontSize="Small" TextColor="Gray" VerticalOptions="Center"/> <Label HorizontalOptions="EndAndExpand" Text="WIĘCEJ" TextColor="DarkGray" FontSize="Medium" Margin="5" FontAttributes="Bold"/> </StackLayout> </StackLayout> </Frame> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>
And my code behind populating items:
`
protected override void OnAppearing()
{
GetAllProfileData();
base.OnAppearing();
}
private async void GetAllProfileData()
{
var result = await DependencyService.Get<IFirebaseAuthenticator>().GetAllUserData();
PopulateProfile(result);
}
private void PopulateProfile(List<UserData> userData)
{
usersList.ItemsSource = userData;
}
`
And a giphy with behaviour.
(I can't post Links )