Articles in this section
Category / Section

How to show the busy indicator while loading the .NET MAUI ListView ?

3 mins read

The .NET MAUI ListView (SfListView) allows you to display the SfBusyIndicator while loading the bound items. The busy indicator can be enabled and disabled by using the IsRunning property.

XAML

Bind the ViewModel.IsLoading property to the SfBusyIndicator.IsRunning property to enable or disable the busy indicator in the view until items are loaded in the SfListView

<ContentPage xmlns:listview="clr-namespace:Syncfusion.Maui.ListView;assembly=Syncfusion.Maui.ListView"
             xmlns:busyIndicator="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core”>
  <Grid>
     <listview:SfListView x:Name="listView" 
                             ItemsSource="{Binding BookInfo}" 
                             ItemSize="110">
     </listview:SfListView>
 
     <busyIndicator:SfBusyIndicator x:Name="busyIndicator" 
                                       AnimationType="SingleCircle" 
                                       IsRunning="{Binding IsLoading, Mode=TwoWay}" 
                                       TextColor="Magenta"
                                       SizeFactor="0.5"/>
  </Grid>
</ContentPage>

C#

In behavior class, set the IsLoading property value to true and false based on items generation using the Loaded event.

public class Behavior:Behavior<ContentPage>
    {
        SfListView listView;
        BookInfoViewModel viewModel;
        protected override void OnAttachedTo(ContentPage bindable)
        {
            base.OnAttachedTo(bindable);
            listView = bindable.FindByName<SfListView>("listView");
            viewModel = new BookInfoViewModel();
            bindable.BindingContext = viewModel;
            listView.Loaded += ListView_LoadedAsync;
 
        }
 
        private async void ListView_LoadedAsync(object sender, ListViewLoadedEventArgs e)
        {
            viewModel.IsLoading = true;
            await Task.Delay(2000);
            viewModel.GenerateItems();
            if (listView.IsLoaded)
            {
                viewModel.IsLoading = false;
            }
        }
 
        protected override void OnDetachingFrom(ContentPage bindable)
        {
            base.OnDetachingFrom(bindable);
            listView = null;
            viewModel = null;
            listView.Loaded -= ListView_LoadedAsync;
        }
    }
Output

To show the busy indicator while loading the .NET MAUI ListView (SfListView)

Download the complete sample on GitHub.

Conclusion

I hope you enjoyed learning how to show the busy indicator while loading the .NET MAUI ListView.

You can refer to our .NET MAUI ListView feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. Explore our .NET MAUI ListView demo to understand how to create and manipulate data.

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

Please let us know in the comments section if you have any queries or require clarification. 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  to leave a comment
Access denied
Access denied