We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to display a busy indicator when refreshing the data source asynchronously?

An animation can be displayed when refreshing the data source asynchronously by adding an UIActivityIndicatorView in the view.

Refer the below code example in which an UIActivityIndicatorView is used to display an animation when the grid is refreshed in a button click.

public MyViewController()

{

   sfDataGrid = new SfDataGrid();

   viewModel = new ViewModel();

   sfDataGrid.ItemsSource = viewModel.OrdersInfo;

   activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray);

   refresh_button = new UIButton();

   refresh_button.TouchUpInside += Refresh_button_TouchUpInside;

   refresh_button.SetTitle ( "Refresh",UIControlState.Normal);

   refresh_button.SetTitleColor(UIColor.Black,UIControlState.Normal);

   View.AddSubview(refresh_button);

   View.AddSubview(sfDataGrid);

   View.AddSubview(activityIndicator);

   View.BackgroundColor = UIColor.White ;

}

 

private async void Refresh_button_TouchUpInside(object sender, EventArgs e)

{

     activityIndicator.Frame = new CoreGraphics.CGRect(0, 50, this.View.Frame.Width, this.View.Frame.Height);

     activityIndicator.StartAnimating();

     await Task.Delay(new TimeSpan(0, 0, 3));

    viewModel.LoadMoreItems();

   activityIndicator.StopAnimating();

}

 

Note: If the data source implements ICollectionChanged interface, then SfDataGrid will automatically refresh the view when an item is added, removed or cleared. If the data model implements the INotifyPropertyChanged interface, then the SfDataGrid responds to the property change in runtime to update the view.

Screenshot

                C:\Users\pavithra.sivakumar\AppData\Local\Microsoft\Windows\INetCacheContent.Word\refreshin ios.png

 

Sample Link

How to display a busy indicator when refreshing the data source asynchronously?

Article ID: Published Date: Last Revised Date: Platform: Control:
7375 01/31/2017 01/31/2017 Xamarin.iOS SfDataGrid
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.