Start PullToRefresh Programatically with refreshing animation

Hi,

I'm trying to add the pull-to-refresh functionality to a ListView. It's working great (I only tested it on Android though), but I want the refresh command and the refresh animation to start when the view is shown.

My ListView:
listView = new ListView { RowHeight = 70, ItemTemplate = new DataTemplate(typeof(NodeItemCell)), RefreshCommand = new Command(() => { ReadNodes(); }), IsRefreshing = true, IsPullToRefreshEnabled = true, };
I'm doing this on the OnAppearing() method:

protected override void OnAppearing () { //.... Device.BeginInvokeOnMainThread(() => { listView.IsRefreshing = true; listView.BeginRefresh(); }); //.... }

The command is executed as it should be but the refreshing icon doesn't appear.

I know this can be done in java, because I have a similar app made in java and it's working like I intended by doing this:
// java code: protected void onCreate(Bundle savedInstanceState) { //... swipeContainer = (SwipeRefreshLayout) findViewById(R.id.swipeContainer); swipeContainer.post(new Runnable() { @Override public void run() { swipeContainer.setRefreshing(true); } }); //...

So the question is if this can be achieved in Xamarin.Forms or if I'm misusing the library.

Thanks in advance!

Answers

  • No answer but this same problem is discussed here.

  • zRGzRG PTMember

    Manuel Perez, have you accomplished this?

  • erickalves05erickalves05 BRMember

    I've just used the listView.BeginRefresh(); and it worked as expected, showing the loader.

    protected override void OnAppearing () { //.... Device.BeginInvokeOnMainThread(() => { //listView.IsRefreshing = true; listView.BeginRefresh(); }); //.... }

Sign In or Register to comment.