在 XAML 和後面的程式碼中拉到重新整理
要在 Xamarin 中的 ListView
中啟用 Pull to Refresh,首先需要指定啟用 PullToRefresh
,然後指定要在提取 ListView
時呼叫的命令的名稱:
<ListView x:Name="itemListView" IsPullToRefreshEnabled="True" RefreshCommand="Refresh">
在後面的程式碼中可以實現相同的目的:
itemListView.IsPullToRefreshEnabled = true;
itemListView.RefreshCommand = Refresh;
然後,你必須指定 Refresh
Command 在你的程式碼中執行的操作:
public ICommand Refresh
{
get
{
itemListView.IsRefreshing = true; //This turns on the activity
//Indicator for the ListView
//Then add your code to execute when the ListView is pulled
itemListView.IsRefreshing = false;
}
}