Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Xamarin ListView Cahcing Strategy show "Ambiguous Reference"?

Below is a screenshot of a page in the "core" project. When adding CachingStrategy="RecycleElement", I receive an

"Ambiguous Reference" error.

Hovering over it does not give any additional information on how to fix it, neither does ReSharper.

https://i.stack.imgur.com/KSEt5.png

like image 496
Shaku Avatar asked Nov 04 '16 05:11

Shaku


2 Answers

You can specify RecycleElement in the ListView constructor instead using x:Arguments

<ListView ...>
  <x:Arguments>
    <ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
  </x:Arguments>
</ListView>
like image 148
LentoMan Avatar answered Nov 20 '22 05:11

LentoMan


ReSharper is simply unable to see that property because it does not really exist or at least ReSharper is not able to detect it (read that paragraph for Xamarin saying this). Xamarin Forms does some tricky stuff (I think they use PInvoke or a compiler trick but cannot quite remember), when the code gets compiled, in order to change your ListView code when that property is specified and ReSharper is not aware that it is going on. Hopefully ReSharper will fix this in an update though I am not sure if they ever will.

like image 2
hvaughan3 Avatar answered Nov 20 '22 03:11

hvaughan3