0

I am working on an issue with UWP application with Xamarin.Forms. I have noticed that list view items by default are getting recycled and reused in UWP. For an instance when I update the first item in a list view (either the new values or even the style), the forth, the seventh, the tenth and so on items in the list are getting updated with the same value or style. According to this article, this is a Behavior by Design.

I have tried couple of experimental ways and also workarounds that have been suggested in this article also setting ListViewCachingStrategy, to override or disable it, but I had no chance of fixing it.

Has anyone faced this problem?! Is there anyway at all that UI virtualization can be disabled or overridden on UWP windows mobile 10?

ssmsexe
  • 201
  • 4
  • 10

1 Answers1

0

You could try using ListViewCachingStrategy from the documentation it says:

Indicates that for every item in the List View's ItemsView.ItemsSource property, a single unique element will be constructed from the DataTemplate.

You can either use it in code like so:

var listView = new ListView(ListViewCachingStrategy.RecycleElement);

or in xaml:

<ListView CachingStrategy="RecycleElement">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
              ...
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

More information on using this here

Whether the Xamarin.Forms team have implemented this properly for Windows 10 mobile is another question

user1
  • 15,594
  • 12
  • 96
  • 166
  • I have tried to set ListViewCachingStrategy before and had observed the same behavior. Thanks for the answer anyways, but I'm seeking either an answer or a workaround for the latter question. – ssmsexe Jul 27 '17 at 21:55
  • @DeveloperX you could build your own control which is a `ScrollView` containing a `StackLayout` with `listview items` in the `StackLayout` this would essentially be a list without virutalisation. But I wouldn't advise doing this as performance would be terrible. I think from your question it sounds like a `Xamarin` bug and should be filed [here](https://bugzilla.xamarin.com/) – user1 Jul 28 '17 at 08:05
  • Thank you for the hint . . . Honestly, I ended up writing a custom renderer and wiring it up it up to a UWP custom control . . . As you pointed out it is not the best solution, but at least it works . . . – ssmsexe Jul 28 '17 at 08:32