When i am scrolling in CollectionView it starts to lag, probably loading of next pictures. What can i do with that? How can i optimize it?
Here is XAML:
<Grid BackgroundColor="#00aeef">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<CollectionView x:Name="myCollectionView" Grid.Row="0">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout>
<Frame Padding="0" BackgroundColor="#00d2ff" Margin="20" CornerRadius="30">
<StackLayout Padding="20">
<Label Text="{Binding Airline}" TextColor ="White" FontSize="30" HorizontalOptions="Center"/>
<Image Source="{Binding Url}" HeightRequest="200"/>
<Label Text="{Binding Plane, StringFormat='Plane: {0}'}" TextColor ="White" FontSize="15"/>
<Label Text="{Binding Airline, StringFormat='Airline: {0}'}" TextColor ="White" FontSize="15"/>
<Label Text="{Binding Livery, StringFormat='Livery: {0}'}" TextColor ="White" FontSize="15"/>
<Label Text="{Binding Registration, StringFormat='Reg: {0}'}" TextColor ="White" FontSize="15"/>
<Label Text="{Binding Airport, StringFormat='Airport: {0}'}" TextColor ="White" FontSize="15"/>
<Label Text="{Binding Date, StringFormat='Date: {0}'}" TextColor ="White" FontSize="15"/>
<Label Text="{Binding Comment, StringFormat='Comment: {0}'}" TextColor ="White" FontSize="15"/>
</StackLayout>
</Frame>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
And here is my code:
public ShowPlanes()
{
InitializeComponent();
var db = new SQLiteConnection(_dbPath);
var data = db.Table<Airplane>().ToList();
myCollectionView.ItemsSource = data;
NavigationPage.SetHasNavigationBar(this, false);
}
question from:
https://stackoverflow.com/questions/65642643/when-scrolling-in-collectionview-pictures-in-xamarin-its-laging-what-to-do 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…