Reputation: 123
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?
Upvotes: 0
Views: 586
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:
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