Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

ActivityIndicator in a ViewCell

$
0
0

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!


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>