【发布时间】:2018-04-22 19:00:25
【问题描述】:
我正在尝试将一个充满图像的文件夹加载到 Flipview 中,如果该文件夹位于项目本身内,则没有问题,但如果我尝试使用不同的位置,Fliview 将加载空项目。
XAML:
<FlipView x:Name="FVtest" HorizontalAlignment="Center" VerticalAlignment="Center" Width="750" Height="750">
<FlipView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}" Stretch="UniformToFill" />
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
代码背后:
public async void Funcion (){
var picker = new Windows.Storage.Pickers.FolderPicker()
{
ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail,
SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Downloads,
SettingsIdentifier = "Setting"
};
picker.FileTypeFilter.Add("*");
Windows.Storage.StorageFolder folder = await picker.PickSingleFolderAsync();
StorageApplicationPermissions.FutureAccessList.AddOrReplace(folder.Name, folder);
String path = folder.Path; //getting the path of a folder selected by the user
String path2 = Directory.GetCurrentDirectory() + @"\Images"; //This one works
FVtest.ItemsSource = Directory.GetFiles(path2);
}
除了最初的问题,这是一种有效的方法吗? 提前致谢
【问题讨论】: