Reputation: 12842
I have about 500 static images as EmbeddedResource
. Right now I show the images with the help of a slider. So when the slider value changes, I load the corresponding image.
private void pageSlider_ValueChanged(object sender, ValueChangedEventArgs e)
{
var newStep = Math.Round(e.NewValue / StepValue);
pageSlider.Value = newStep * StepValue;
pageNumber.Text = pageSlider.Value.ToString();
pageImage.Source = ImageSource.FromResource("SApp.Images.SPages.page" + pageSlider.Value.ToString() + ".jpg",typeof(AboutPage).GetTypeInfo().Assembly);
}
Now, as the slide is not that much user friendly to iterate thru 500 images (total image size 40 MB), what is the right way to load the images.
I thought to load it in Carousal control
, but the current layout is TabbedPage
, so I cannot do this.
Other option is to load all the images to ListView
, but will it make issue with memory ? Or ListView
with Paging
?
Upvotes: 0
Views: 187
Reputation: 9681
CollectionView
and Load data incrementally. Or use it pull to refresh capability by wrapping it inside a RefreshView
, you will be able to load your images async.Edit
From source:
CollectionView is a view for presenting lists of data using different layout specifications. It aims to provide a more flexible, and performant alternative to ListView.
For information, you can use Pull to Refresh (Xamarin.Forms RefreshView) in both ListView
or CollectionView
.
Upvotes: 1
Reputation: 10346
I thought to load it in Carousal control, but the current layout is TabbedPage, so I cannot do this. Other option is to load all the images to ListView, but will it make issue with memory ? Or ListView with Paging ?
Maybe you can try to use FFImageLoading to display image in ListView, or just update image source when silder value update.
There are some features:
Configurable disk and memory caching
Multiple image views using the same image source (url, path, resource) will use only one bitmap which is cached in memory (less memory usage)
Error and loading placeholders support
Images can be automatically downsampled to specified size (less memory usage)
Upvotes: 2