[英]Xamarin.Forms PullToRefresh not occuring when ListView is empty?
在Xamarin.Forms中,我有一個簡單的ListView,它使用MVVM綁定到視圖模型。
<ListView Grid.Row="1"
ItemsSource="{Binding ContactsGrouped}"
IsGroupingEnabled="true"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding RefreshCommand}"
IsRefreshing="{Binding IsRefreshing}"
GroupDisplayBinding="{Binding Key}"
GroupShortNameBinding="{Binding Key}"
BackgroundColor="Transparent"
SelectionMode="Single"
HasUnevenRows="true"
SeparatorColor="#cccccc">
<ListView.ItemTemplate>
<cr:MyItemTemplate>
</ListView.ItemTemplate>
</ListView>
這是我的xaml代碼,如果列表中至少有1個項目,則可以很好地工作。 通過點擊並下拉該項目,列表視圖會刷新,但是點擊並下拉該項目外部的列表不會導致PullToRefresh發生。 就像ListView具有透明輸入一樣,但是其項沒有透明輸入,因此可以正常工作。
示例圖像中紅色區域中的任何紅色部分都顯示了一個區域,如果我點擊並向下拖動活動指示器,該區域會很好顯示,並進行刷新。 點擊並拖動到綠色的任何位置都會導致視圖不刷新,並且活動指示符也不會出現。
我不會顯示視圖模型,因為問題在於視圖。 我還嘗試將背景色設置為紅色,檢查透明是否引起問題,可惜情況並非如此。 有任何想法嗎?
嘗試添加VerticalOptions =“ StartAndExpand”。
<ListView Grid.Row="1"
ItemsSource="{Binding ContactsGrouped}"
IsGroupingEnabled="true"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding RefreshCommand}"
IsRefreshing="{Binding IsRefreshing}"
GroupDisplayBinding="{Binding Key}"
GroupShortNameBinding="{Binding Key}"
BackgroundColor="Transparent"
SelectionMode="Single"
HasUnevenRows="true"
SeparatorColor="#cccccc"
VerticalOptions="StartAndExpand">
<ListView.ItemTemplate>
<cr:MyItemTemplate>
</ListView.ItemTemplate>
</ListView>
該屬性告訴View應該覆蓋屏幕的多少空間。 如果不添加它,則視圖將僅覆蓋顯示其所需數據所需的任何長度。
我只是在我這邊轉載了你的問題。 經過一些研究,我發現它是Xamarin.forms 3.5.0中的已知問題,並且仍然存在於Latest stable 3.6.0.344457
。
WorkAround將Xamarin.forms版本降級為3.4.0
。
另外,我在最新的預發行版4.0.0.394984-pre10
對其進行了測試,並且效果很好。 因此,我相信此問題將在下一發行版中解決。
您可以按照此問題檢查過程。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.