Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

ActivityIndicator in a ViewCell

AaronGoodmillerAaronGoodmiller USMember
edited November 2015 in Xamarin.Forms

I have an ActivityIndicator embedded in a ViewCell. I am trying to get the ActivityIndicator in the specific ViewCell to start once it is tapped, but I can't seem to find the right code to make it visible and running.

Here is my XAML code for my ListView and ViewCell. I have the ActivityIndicator named, but I can't seem to access it in the code:

<ListView x:Name="allLocations" ItemsSource="{Binding .}" ItemTapped="OnItemTapped" > <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Grid VerticalOptions="Center" HorizontalOptions="StartAndExpand"> <Grid.ColumnDefinitions> <ColumnDefinition Width="5" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="10" /> </Grid.ColumnDefinitions> <StackLayout VerticalOptions="Center" Grid.Column="1"> <Label Text="{Binding LocationName}" Font="Bold,Medium" /> <Label Text="{Binding LocationAddress}" Font="Small" TextColor="Accent" /> </StackLayout> <ActivityIndicator Grid.Column="2" x:Name="theIndicator" IsVisible="false" IsRunning="false" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" BackgroundColor = "Gray" Opacity = ".5"/> </Grid> </ViewCell> </DataTemplate> </ListView.ItemTemplate>

this is my code for OnItemTapped:

    async void OnItemTapped(object sender, ItemTappedEventArgs e)
    {
        TheLocation tappedItem= (TheLocation) allLocations.SelectedItem;

        // Need Something Here to turn on the ActivityIndicator

        await this.Navigation.PushAsync(new LocationBusArrivals(tappedItem.LocationID, tappedItem.LocationName));
        System.Diagnostics.Debug.WriteLine ("***end OnItemTapped***");
    }

So my main questions would be.. what am I missing? and is this even possible?

Thanks!

Best Answer

Answers

  • That's it! worked like a champ. Thank you Sir/Ma'am!

    Now if only i could get the ActivityIndicator to show up before the next screen slides over.

Sign In or Register to comment.