title: How can I implement an Activity Indicator for a Carousel in Xamarin.Forms?
body: <p>I'm trying to incorporate an ActivityIndicator before launching a Carousel page; so that when the Carousel page is heavy on content; the user will know that the app is still loading / hasn't hung.</p>
  
  <p>To figure this out, I'm working from this sample which uses a Carousel page:
  <a href="https://github.com/chrisriesgo/xamarin-forms-carouselview" rel="nofollow noreferrer">https://github.com/chrisriesgo/xamarin-forms-carouselview</a></p>
  
  <p>My main approach was trying to modify the button to create an ActivityIndicator within the button command: </p>
  
  <h1>Original Sample from "SwitcherPage.cs"</h1>
  
  <pre><code>var none = new Button {
              HorizontalOptions = LayoutOptions.Center,
              Text = "No pager indicator",
              Command = new Command((obj) =&gt; Navigation.PushAsync(new HomePage(CarouselLayout.IndicatorStyleEnum.None)))
          };
  </code></pre>
  
  <h1>My Attempt</h1>
  
  <pre><code>var indicator = new ActivityIndicator ();
  
          var none = new Button {
              HorizontalOptions = LayoutOptions.Center,
              Text = "No pager indicator",
              Command = new Command(
                  indicator.IsRunning,
                  indicator.IsVisible,
                  Task.Delay(2500), // to simulate a long loading time
                  (obj) =&gt; Navigation.PushAsync(new HomePage(CarouselLayout.IndicatorStyleEnum.None)))
          };
  </code></pre>
  
  <h1>What I know so far</h1>
  
  <p>Intellisense is already telling me that's wrong; I can't define it in the command that way. But hopefully that illustrates what I'm trying to do; essentially trigger an activity indicator while waiting for the page to load. </p>
  
  <p>I've looked for general resources on the ActivityIndicator, but the problem is I haven't found any that I can figure out how to convert that to something that will activate after the button is pressed while waiting for the Carousel page to load. </p>
  
  <p><a href="https://developer.xamarin.com/api/type/Xamarin.Forms.ActivityIndicator/" rel="nofollow noreferrer">https://developer.xamarin.com/api/type/Xamarin.Forms.ActivityIndicator/</a>
  <a href="http://forums.xamarin.com/discussion/34502/xamarin-forms-activity-indicator" rel="nofollow noreferrer">http://forums.xamarin.com/discussion/34502/xamarin-forms-activity-indicator</a>
  <a href="https://stackoverflow.com/questions/24885525/xamarin-forms-how-to-overlay-an-activityindicator-in-the-middle-of-a-stacklayo">Xamarin.Forms - How to overlay an ActivityIndicator in the middle of a StackLayout programmatically</a></p>