Deepak Sharma
Deepak Sharma

Reputation: 476

Using FileOpenPicker in Windows 8 Store Apps to browse your own resource directory on page startup

I have a windows 8 Store App page(say PhotoPage.xaml). In my app I have an embedded Image resource folder in "Assets\Images" in which I have many images present.

Image Folder in App

Is there a way to populate all the images inside this Images folder on page load of the "PhotoPage.xaml" page.

I tried FileOpenPicker but I guess I cant browse a custom folder on SuggestedStartLocation.

Here is what I tried :

Windows.Storage.Pickers.FileOpenPicker openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;

According to this PickerLocationId can have only few locations..

So is there any way to browse my Images folder on startup(page load) of my PhotoPage.xaml page.

Any help is appreciated.

Thanks & Regards,

Upvotes: 0

Views: 336

Answers (1)

IUnknown
IUnknown

Reputation: 335

I don't think you need to use FileOpenPicker. If you want to populate all the images just get the the Images folder and iterate over its content.

var installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
var images = await installedLocation.GetFolderAsync("Assets\\Images");
var items = await images.GetItemsAsync();

foreach (var item in items)
{
    // TODO: add image to the Page
}

Upvotes: 1

Related Questions