2016-11-04 23 views
8

下面是「核心」項目中頁面的截圖。當添加CachingStrategy="RecycleElement"時,我收到一個爲什麼Xamarin ListView Cahcing Strategy顯示「模糊引用」?

「不明確的參考」錯誤。

懸停在它上面並沒有提供任何有關如何解決它的額外信息,ReSharper也沒有。

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

+0

你解決了嗎? –

+0

不幸的是,沒有。花了3〜4天把我的頭髮撕掉,但沒有運氣。 – Shaku

+1

我似乎無法重現與XVS 4.2.1.60和XF 2.3.2。你能確認這些版本嗎? – therealjohn

回答

11

您可以在ListView構造函數,而不是用x指定RecycleElement:參數

<ListView ...> 
    <x:Arguments> 
    <ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy> 
    </x:Arguments> 
</ListView> 
+0

謝謝!那就是訣竅。 – Shaku

2

ReSharper的是根本無法看到的財產,因爲it does not really exist or at least ReSharper is not able to detect it(讀這一段的Xamarin說這句話)。當代碼被編譯時,Xamarin Forms會做一些棘手的事情(我認爲他們使用PInvoke或編譯器技巧,但不能完全記住),以便在指定該屬性時更改ListView代碼,並且ReSharper不知道它正在進行。希望ReSharper能夠在更新中解決這個問題,儘管我不確定他們是否會這樣做。

0

只需添加類

public class CachedListView : ListView 
{ 
    public CachedListView() : base(ListViewCachingStrategy.RecycleElement) { } 
} 

而在XAML中使用CachedListView代替ListView控件。

0

當使用上述方法顯示 "Error CS0234 The type or namespace name 'CachedListView' does not exist in the namespace 'Xamarin.Forms' (are you missing an assembly reference?)"添加x:Arguments是否需要添加?或者是否需要給予參考

xmlns:local ="clr-namespace:TestProject.Data" 
+0

我使用上述方法並得到相同的錯誤,請讓我知道如果你解決了,謝謝 – pan