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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: Xamarin.iOS |
Control: SfDataGrid |
Published Date: January 31, 2017 |
Last Revised Date: January 31, 2017
Tags: general

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?

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon