【发布时间】:2019-05-05 21:41:31
【问题描述】:
在 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 有透明的输入,但它的项目没有,因此允许它工作。
我的示例图像中的任何红色部分都显示了如果我点击并向下拖动活动指示器的区域,则该区域显示正常并且会发生刷新。然而,点击并拖动绿色的任意位置会导致视图不刷新并且活动指示器不出现。
我不会显示我的视图模型,因为问题在于视图。我还尝试将背景颜色设置为红色,检查透明是否导致问题,遗憾的是事实并非如此。有什么想法吗?
【问题讨论】:
-
从项目外拉下来是什么意思?如果listView为空,拉动刷新时能看到Activity Indicator吗?
标签: c# xaml xamarin.forms