为什么我的 Xamarin.Forms UWP 的 ListView 不提供“拉动滚动”行为?
Why doesn’t my Xamarin.Forms UWP’s ListView provide the “pull to scroll” behaviour?
我正在构建一个 Xamarin.Forms UWP 应用程序,我在其中提供了一个 ListView
从页面的代码隐藏填充:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage ...>
<ContentPage.Content>
<ListView IsPullToRefreshEnabled="True"
ItemsSource="{Binding Items, Mode=OneWay}"
IsRefreshing="{Binding IsRefreshing, Mode=OneWay}"
RefreshCommand="{Binding RefreshCommand}"/>
</ContentPage.Content>
</ContentPage>
bind 可以正常工作,但问题是我不明白为什么我无法拉动以刷新列表。该列表只是静态的;我只能使用鼠标滚轮或滚动条向上或向下滚动。页面的隐藏代码是这样的:
public partial class MainPage {
public MainPage() {
BindingContext = this;
Items = new ObservableCollection<string> { "Hi", "Hi", "Hi", "Hi", "Hi", "Hi" };
RefreshCommand = new Command(async () => {
IsRefreshing = true;
await RefreshData();
IsRefreshing = false;
});
InitializeComponent();
}
private bool _isRefreshing = false;
public bool IsRefreshing {
get { return _isRefreshing; }
set {
_isRefreshing = value;
OnPropertyChanged(nameof(IsRefreshing));
}
}
public ObservableCollection<string> Items { get; }
public ICommand RefreshCommand { get; }
private async Task RefreshData() { /* ... */ }
}
你能帮我找出问题吗?
PullToRefresh 未在 ListViewRender.cs 的 UWP 版本中实现。如果您在 Xamarin.Forms 源中搜索 IsPullToRefreshEnabled,您将只能在 ListViewRenderer 的 iOS 和 Android 实现中找到它。
这在以下错误报告中进行了讨论,目前建议使用 RefreshView:
PullTORefresh is not working for the UWP platform using XamarinForms ListVIew
Please try the RefreshView instead. Thanks!
我正在构建一个 Xamarin.Forms UWP 应用程序,我在其中提供了一个 ListView
从页面的代码隐藏填充:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage ...>
<ContentPage.Content>
<ListView IsPullToRefreshEnabled="True"
ItemsSource="{Binding Items, Mode=OneWay}"
IsRefreshing="{Binding IsRefreshing, Mode=OneWay}"
RefreshCommand="{Binding RefreshCommand}"/>
</ContentPage.Content>
</ContentPage>
bind 可以正常工作,但问题是我不明白为什么我无法拉动以刷新列表。该列表只是静态的;我只能使用鼠标滚轮或滚动条向上或向下滚动。页面的隐藏代码是这样的:
public partial class MainPage {
public MainPage() {
BindingContext = this;
Items = new ObservableCollection<string> { "Hi", "Hi", "Hi", "Hi", "Hi", "Hi" };
RefreshCommand = new Command(async () => {
IsRefreshing = true;
await RefreshData();
IsRefreshing = false;
});
InitializeComponent();
}
private bool _isRefreshing = false;
public bool IsRefreshing {
get { return _isRefreshing; }
set {
_isRefreshing = value;
OnPropertyChanged(nameof(IsRefreshing));
}
}
public ObservableCollection<string> Items { get; }
public ICommand RefreshCommand { get; }
private async Task RefreshData() { /* ... */ }
}
你能帮我找出问题吗?
PullToRefresh 未在 ListViewRender.cs 的 UWP 版本中实现。如果您在 Xamarin.Forms 源中搜索 IsPullToRefreshEnabled,您将只能在 ListViewRenderer 的 iOS 和 Android 实现中找到它。
这在以下错误报告中进行了讨论,目前建议使用 RefreshView:
PullTORefresh is not working for the UWP platform using XamarinForms ListVIew
Please try the RefreshView instead. Thanks!