ozmert75
ozmert75

Reputation: 123

Xamarin Forms - Listview - Save PDF on tap

When I click on the ListItem, which is a .PDF, in my ListView, I want to save the file locally. Each ListItem has a different Uri.

Is there any way I can do that?

enter image description here

Upvotes: 0

Views: 586

Answers (1)

Raven
Raven

Reputation: 2257

Currently, it's a bit tricky to implement from scratch a ListView onTap gesture - but you can use a nuget that gives that functionality for Xamarin Forms:

http://www.michaelridland.com/xamarin/freshessentials-for-xamarin-forms-the-must-have-nuget-for-forms/

Basically, in order to use it you can just add a property to your ListView and Bind it to a Command to your CodeBehind or ViewModel (if you're following an MVVM pattern or framework):

<ListView ItemsSource="{Binding MyCars}" fe:ListViewItemTappedAttached.Command="{Binding ItemTapCommand}">

Don't forget to add this resource as property/namespace of your ContentPage tho: xmlns:fe="clr-namespace:FreshEssentials;assembly=FreshEssentials"

Ex.

<ContentPage xmlns:fe="clr-namespace:FreshEssentials;assembly=FreshEssentials" ... />

On Saving files - Because Xamarin.Forms runs on multiple platforms, each with its own filesystem, there is no single approach for loading and saving files created by the user.

You can follow this guide from Xamarin to know how to do that for every platform you are targeting: https://developer.xamarin.com/guides/xamarin-forms/working-with/files/#Loading_and_Saving_Files

Upvotes: 0

Related Questions