How to know when the user has swiped or arrived at the last item of the carousel in CardsView

dylancheongdylancheong Member ✭✭

``XAML FILE

        {


<Cards:CarouselView.ItemTemplate>







</Cards:CarouselView.ItemTemplate>


}

        < StackLayout Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalOptions="Center" HorizontalOptions="Fill" Padding="0" Margin="0">
            < ActivityIndicator x:Name="activityIndicator" IsRunning="{Binding IsBusy}" VerticalOptions="Center" HorizontalOptions="Center " Color="White"/>
        </ StackLayout>

CS FILE

public async void GetPDF()
{

        HttpClient client = new HttpClient();
        string req = "link" + id;
        var response = await client.GetStringAsync(req);

        var details = JsonConvert.DeserializeObject<List<table>>(response);

        cardPDF.ItemsSource = details;

        imageCount = cardPDF.ItemsSource.Count();


        for(int i = 0; i < imageCount; i++)
        {
            complete.IsVisible = false;

        }

        complete.IsVisible = true;

    }

Best Answer

  • JarvanJarvan Xamurai
    Accepted Answer

    You can refer to ListView.ItemAppearing event. This method is guaranteed to fire at some point before the element is on screen.

    listview.ItemAppearing += (sender, e) => 
    {
        if(isLoading || Items.Count == 0)
            return;
        if(e.Item.ToString() == Items[Items.Count - 1])
        {
            //
        }
    };
    

Answers

  • dylancheongdylancheong Member ✭✭
    edited July 26
  • JarvanJarvan Member, Xamarin Team Xamurai
    Accepted Answer

    You can refer to ListView.ItemAppearing event. This method is guaranteed to fire at some point before the element is on screen.

    listview.ItemAppearing += (sender, e) => 
    {
        if(isLoading || Items.Count == 0)
            return;
        if(e.Item.ToString() == Items[Items.Count - 1])
        {
            //
        }
    };
    
  • dylancheongdylancheong Member ✭✭

    @yelinzh Thanks!

Sign In or Register to comment.