Articles in this section
Category / Section

How to display a busy indicator when refreshing the data source asynchronously in Xamarin.iOS DataGrid?

1 min read

An animation can be displayed when refreshing the data source asynchronously in Xamarin.iOS DataGrid 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?


Conclusion

I hope you enjoyed learning about how to display a busy indicator when refreshing the data source asynchronously in Xamarin.iOS DataGrid.

You can refer to our Xamarin.Forms DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Xamarin.Forms DataGrid example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial

to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied