I am trying to load a folder full of images into a Flipview, if that folder is inside the project itself there is no problem, but if i try with a different location, the Fliview is loaded with empty items.
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>
Code Behind:
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);
}
Besides the initial problem, is this an efficient approach? Thanks in advance
Generally, to get all the image files, we should add the image
FileTypeFilter, such as.pngand.jpgand use the StorageFolder.GetFilesAsync Method to get all the image files, then we can show all the images.Here is the code example: