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.

Example of XAML Usage in ListView with ListViewCachingStrategy.RecycleElement enabled using normal ViewCell

See original GitHub issue

I tried following instructions on this page and that page too but both show code-behind implementation (non XAML). In case of XAML, if I have the following list view with normal view cell, what should I do to set OnBindingContextChanged of ViewCell to be compatible with Recycle Caching Strategy?

    <ListView x:Name="listView" CachingStrategy="RecycleElement">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <ViewCell.View>
                                <StackLayout Orientation="Horizontal">
                                                              <ffimageloading:CachedImage HorizontalOptions="Center" VerticalOptions="Center"  WidthRequest="300" HeightRequest="300" DownsampleToViewSize="true" />
                                    <Label Text="{Binding Name}"/>
                                </StackLayout>
                            </ViewCell.View>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
molinchcommented, May 15, 2016

@daniel-luberda Maybe wiki could be improved regarding Recycle strategy? So we have the XAML example too

1reaction
daniel-luberdacommented, May 15, 2016

@Korayem You should create separate XAML view for a cell (separate file: Add File -> Forms ContentView XAML), then use it in your page:

<ListView x:Name="listView" CachingStrategy="RecycleElement">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <ViewCell.View>
                    <local:YourCustomView/>
                </ViewCell.View>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Then override OnBindingContextChanged method in YourCustomView.xaml.cs file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ListView Performance - Xamarin
When a ListView uses a DataTemplateSelector to select a DataTemplate , the RecycleElement caching strategy does not cache DataTemplate s.
Read more >
ListViewCachingStrategy Enum (Xamarin.Forms)
Indicates that, in addition to the behavior specified by RecycleElement, DataTemplate objects that are selected by a DataTemplateSelector are cached by the data ......
Read more >
Creating Custom Controls Part 1: ExtendedListView Endless ...
Our first use case to dive into creating custom controls will be the ... public ExtendedListView(ListViewCachingStrategy cachingStrategy) ...
Read more >
Xamarin.Forms, iOS only, Content of a frame that is the ...
Forms version (4.7.0.1080) and now a list view I have in my project is totally messed up - the template of the list...
Read more >
CachingStrategy="RecycleElement", ListView Performance ...
I tried to set it on the RADListView but got no property found. I am using the grid layout format for the ListView....
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