A portion of xaml below. App Throws/Raises no any error. also App generates exact slides count. but just getting gray empty areas. it slides; but areas are empty.
<FlipView x:Name="flipView1"">
<FlipView.ItemTemplate>
<DataTemplate>
<Image>
<Image.Source>
<BitmapImage UriSource="{Binding PicFiles}" />
</Image.Source>
</Image>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
and codebehind
public sealed partial class PresentationPage : Page
{
public ObservableCollection<Uri> PicFiles;
public PresentationPage()
{
this.InitializeComponent();
PicFiles = new ObservableCollection<Uri>();
GetPicFilesFromStorePath();
}
private void GetPicFilesFromStorePath()
{
var path = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
var a = Directory.GetFiles(path, "*.*").Where(x => x.EndsWith(".jpg"));
foreach (var x in a)
{
PicFiles.Add(new Uri(x,UriKind.Absolute));
}
flipView1.ItemsSource = PicFiles;
}
Firstly, the above code get the full file-system path property of the file for accessing, which is not recommended. You could use
StoragFilerelative APIs. Details please reference Skip the path: stick to the StorageFile.QueryOptionscan be used for filtering in your situation.Secondly, give full file-system path value to the
UriSourceproperty will not work. To access files stored in the app data, you should useUriwith thems-appdata:scheme. Details you can reference How to load file resources (XAML).Lastly, the binding is not in the correct way, you're binding the whole collection to the
UriSourceproperty, actually it requires oneUrivalue of the collection.So the updated complete code snippet as follows:
Code behind: