Hello
I have read few blogs but didn't find solution of it.
When I scroll Up/Down, some image misplace and some image disappear. I have review my code and given enough time to get rid of the problem. But unfortunately I didn't find any way to resolve this.
Can anybody please guide me? I check with iOS.
EmployeeResultsPage
<ListView x:Name="EmployeeResultsListView"
ItemsSource="{Binding EmployeeResults}"
RowHeight="200"
IsPullToRefreshEnabled="true"
RefreshCommand="{Binding RefreshDataCommand}"
IsRefreshing="{Binding IsRefreshingData, Mode=OneWay}"
ItemAppearing="Employee_ItemAppearing"
<ListView.ItemTemplate>
<DataTemplate>
<local:EmployeeResultViewCell />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
EmployeeResultsPage.CS
private void Employee_ItemAppearing(object sender, ItemVisibilityEventArgs e)
{
var itemObject = e.Item as ExtendedEmployee;
if (_viewModel.EmployeeResults.Last() == itemObject)
{
if (_viewModel.LoadEmployee.CanExecute(null))
{
_viewModel.LoadEmployee.Execute(null);
}
}
}
EmployeeResultViewModel
[ImplementPropertyChanged]
public class EmployeeResultsViewModel : ViewModelBase
{
private async Task LoadEmployee()
{
EmployeeResults = GetDataUsingAPI(); //15 records per call
}
public ObservableRangeCollection<ExtendedEmployee> EmployeeResults { get; set; }
public string EmployeePhotoUrl { get; set; }
public string EmployeeName { get; set; }
}
EmployeeResultViewCell
<ViewCell.View>
<Grid RowSpacing="0" ColumnSpacing="0" VerticalOptions="Center" HeightRequest="150">
<Image x:Name="EmployeeImage" Grid.Column="0" HeightRequest="150" WidthRequest="150"
Source="{Binding EmployeePhotoUrl}" />
<Label Text="{Binding EmployeeName}" FontSize="18" TextColor="Grey"/>
</Grid>
</ViewCell.View>
CS File
public partial class EmployeeResultViewCell : CustomViewCell
{
public EmployeeResultViewCell()
{
InitializeComponent();
}
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
var employee = (BindingContext as ExtendedEmployee);
}
}