Articles in this section
Category / Section

How to show the busyindicator while loading the SfListView in Xamarin.Forms?

2 mins read

SfListView allows you to displaying the SfBusyIndicator while loading the bounded items. The busy indicator can be enabled and disabled by using IsBusy property.

The below example illustrates to display the busy indicator while loading the SfListView,

Create a IsLoading Boolean property in view model and bind it to the IsBusy property. By setting the value to IsLoading property, the busy indicator will be enabled and disabled into the view until items loaded in the SfListView.

XAML

<ContentPage xmlns:listview="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms"
             xmlns:busyIndicator="clr-namespace:Syncfusion.SfBusyIndicator.XForms;assembly=Syncfusion.SfBusyIndicator.XForms">
  <Grid>
     <listview:SfListView x:Name="listView" 
                             ItemsSource="{Binding ContactInfo}" 
                             ItemSize="110">
     </listview:SfListView>
 
     <busyIndicator:SfBusyIndicator x:Name="busyIndicator" 
                                       AnimationType="SingleCircle" 
                                       IsBusy="{Binding IsLoading, Mode=TwoWay}" 
                                       TextColor="Magenta"
                                       ViewBoxWidth="50"
                                       ViewBoxHeight="50"/>
  </Grid>
</ContentPage>

 

C#

 
public class ViewModel:INotifyPropertyChanged
{
  private bool isLoading = false;
 
  public bool IsLoading
  {
    get { return isLoading; }
    set
    {
      this.isLoading = value;
      OnPropertyChanged("IsLoading");
    }
  }
 
  private async void GenerateItems()
  {
    IsLoading = true;
    await Task.Delay(5000);
    for (int i = 0; i < 30; i++)
    {
      var contact = new Model(CustomerNames[i], ContactNumber[i]);
      ContactInfo.Add(contact);
    }
    IsLoading = false;
  }
}

 

Screenshot:

         XAML Screenshot

Click here to download the sample.

Conclusion

I hope you enjoyed learning about how to show the busyindicator while loading the SfListView in Xamarin.Forms.

You can refer to our Xamarin.Forms ListView feature tour page to know about its other groundbreaking feature representations. You can also explore our Xamarin.Forms ListView documentation 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