Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Start PullToRefresh Programatically with refreshing animation

$
0
0

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!


Viewing all articles
Browse latest Browse all 77050

Trending Articles