For the tablet and desktop versions of the view, we added a button to the toolbar to refresh the weather forecast. In the phone version of the view, however, we will add pull to refresh functionality, which is a common way to refresh content in a list of data. CollectionView in Xamarin.Forms has no built-in support for pull to refresh like ListView has.
Instead, we can use RefreshView. RefreshView can be used to add pull to refresh behavior to any control. Let's set this up:
- Go to MainView_Phone.xaml.
- Wrap CollectionView inside RefreshView.
- Bind the Refresh property in MainViewModel to the Command property of RefreshView to trigger a refresh when the user performs a pull-to-refresh gesture.
- To show a loading icon when the refresh is in progress, bind the IsRefreshing property in MainViewModel to the IsRefreshing property of RefreshView. When we are setting this up, we will also get a loading...