question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with ffimageloading and ObservableCollection

See original GitHub issue

Hi!

I have encountered a problem using CardsView together with FFImageLoading and databinding the ItemsSource property to an ObservableCollection. My environment is xamarin.Forms(Android) with latest everything.

Setup: My ObservableCollection initially holds a single ImageModel (this represents my image) which displays fine on the UI. Then I try to add additional ImageModels to the end of the ObservableCollection (ItemsSource).

The problem: After adding the ImageModels to the end of the collection, only a small subset of images are actually toggled on the display when swiping the CardsView. So the user is displayed only with like 4 or 5 images cyclically even though the collection has 50+ images loaded.

The CardsView.SelectedIndex is correctly updated when cycling through the collection running from 0 to last index. The CardsView.SelectedItem.FilePath property (Url) which equals to ImageModel.FilePath and to which FFImageLoading’s UrImageSource property is bound is correctly displayed on the UI (as a debug label) as the user cycles the images.

BUT the actual displayed CardsView image does not correspond to the displayed CardsView.SelectedItem.FilePath

To gain more information, I have replaced FFImageLoading for XamarinForms.Image and then it works properly. Bug is gone.

Below is the code sniped with PanCardsView.

                        <pancardview:CardsView.ItemTemplate>
                            <DataTemplate>
                                <ContentView>
                                    <Frame                                         
                                        HeightRequest="226"
                                        Padding="0" 
                                        HasShadow="false"
                                        IsClippedToBounds="true"
                                        CornerRadius="10"
                                        BackgroundColor="WhiteSmoke"
                                    >
                                        <ffimageloading:CachedImage 
                                            Aspect="AspectFit"                                            
                                            ErrorPlaceholder="movie_backdrop_placeholder_lg"
                                            RetryCount="1">

                                            <ffimageloading:CachedImage.GestureRecognizers>
                                                <TapGestureRecognizer Command="{Binding  Path=BindingContext.TapImageCommand, Source={x:Reference movieDetailPage}}" />
                                            </ffimageloading:CachedImage.GestureRecognizers>

                                            <ffimageloading:CachedImage.Source>
                                                <UriImageSource
                                                    Uri="{Binding Path=FilePath}"
                                                />
                                            </ffimageloading:CachedImage.Source>                                            
                                        </ffimageloading:CachedImage>
                                    </Frame>                                    
                                </ContentView>
                            </DataTemplate>
                        </pancardview:CardsView.ItemTemplate>

                    </pancardview:CardsView>

                            <Label BindingContext="{x:Reference cardView}"
                               Text="{Binding SelectedIndex, Converter={StaticResource Key=intPlusOneToString}}" 
                               FontSize="Micro" 
                               HorizontalOptions="End" 
                               VerticalOptions="Start"/>
                            
                           <Label BindingContext="{x:Reference cardView}"
                               Text="{Binding SelectedItem.FilePath}" 
                               FontSize="Micro" 
                               HorizontalOptions="End" 
                               VerticalOptions="Start"/>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jungjanoscommented, Aug 16, 2019

Ok, I confirmed that it works!

1reaction
AndreiMisiukevichcommented, Aug 16, 2019

@j4ni try IsViewReusingEnabled = false

Read more comments on GitHub >

github_iconTop Results From Across the Web

FFImageLoading has wrong behavior when resource is not ...
1) I have an XML file with categories and items, I parse it, I have an ObservableCollection, each Category is an ObservableCollection.
Read more >
Newest 'ffimageloading' Questions - Stack Overflow
I have a problem with creating stacklayout, which contains image created from base64string, downloaded from database. Example of image declare: ...
Read more >
Improve CollectionView Performance - Microsoft Q&A
My problem is that the CollectionView is taking too long to change sections. There's a noticeable delay when trying to load up the...
Read more >
ListView binding to ObservableCollection does not update ...
Hello, I have a RadListView bound to an ObservableCollection inside RadSideDrawer.DrawerContent and my ListView doesn't show the items until ...
Read more >
[Code]-Coverting IAsyncEnumerable to ObservableCollection
Just wrap your function call in Task.Run to queue the work to a thread pool thread: var myObservable = await Task.Run(() => myCollection.ToObservable());....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found