当我单击ListView中的ListItem (一个.PDF )时,我希望将文件保存在本地。每个ListItem都有不同的Uri。
我有没有办法做到这一点?

发布于 2016-11-26 23:23:06
目前,从头开始实现ListView onTap手势有点棘手--但您可以使用为Xamarin Forms提供该功能的nuget:
http://www.michaelridland.com/xamarin/freshessentials-for-xamarin-forms-the-must-have-nuget-for-forms/
基本上,为了使用它,您只需将一个属性添加到您的ListView,并将其绑定到您的CodeBehind或ViewModel的命令(如果您遵循的是MVVM模式或框架):
<ListView ItemsSource="{Binding MyCars}" fe:ListViewItemTappedAttached.Command="{Binding ItemTapCommand}">不要忘记添加此资源作为ContentPage的属性/名称空间tho: xmlns:fe="clr-namespace:FreshEssentials;assembly=FreshEssentials“
例如。
<ContentPage xmlns:fe="clr-namespace:FreshEssentials;assembly=FreshEssentials" ... />On Saving files -因为Xamarin.Forms运行在多个平台上,每个平台都有自己的文件系统,所以没有单一的方法来加载和保存用户创建的文件。
你可以按照Xamarin的这个指南来了解如何为你的目标平台做到这一点:https://developer.xamarin.com/guides/xamarin-forms/working-with/files/#Loading_and_Saving_Files
https://stackoverflow.com/questions/40799627
复制相似问题