FileOpenPicker in Windows 8 XAML App


In this article we would see the FileOpenPicker in Windows 8 XAML Application. Basically in Silverlight/WPF we have OpenFileDialog which would open a dialog. FileOpenPicker is native to WinRT.

Let’s Start

Let’s create an instance of FileOpenPicker, which requires “Windows.Storage.Pickers” to be referenced.

Then we would have the initial folder where the picker should point to. As you see, we have many choices, as we are going to do with Images, we will consider Pictures Library.


Then, we have file picker ViewMode, you could ignore this, but if you would like to add; there are two options such as List and Thumbnail. We would select Thumbnail, which is suited for this sample application.

Now, we need to add FileTypeFilter, this is one of the mandatory fields you should add. It requires at least on entry in it.

The FileTypeFilter is a readonly collection, so we would be able to add values.

As we are going to access the Pictures Library, we need permission for that, so open Package.AppManifest and add the “Pictures Library Access checkbox”.


If you would like to add additional declarations for File Open Picker, then you could add it on the Declarations Tab.


The first screen it shows with multiple validations. That is because the we have not selected the files it should associate to.


We have two options:

  1. Either we would go with “Support any file type”
  2. Or add file types as single-single entry.

As we are handling images, let’s do the option 2; where we would add 3 entries such as “.jpg”, “.png”, and “.bmp”.



Single File Picker

If you would like to give privilege to the user for single file pick; then you could following.

We are checking for the file NULL, because when you press cancel in the File Picker the file would be NULL.


And we are able to show the single file selected to the view.

Multiple Files Picker

To have multiple files privilege to the user, you should the following; where a checkbox value is given. The checkbox is optional. If you would like to give both single and multiple privileges then you could use a checkbox to select the option.

The file picker would give the selected image thumbnails at the bottom.


And we are able to select multiple files and see it in the view.


Source Code: Click Here

Article as PDF: Click Here

Related Posts:

1) FileSavePicker in Windows 8 XAML App

2) Data Template Selector in Windows 8 Metro XAML App

3) Save as Image in Picture Library in Windows 8 XAML Metro App

4) Remove Windows 8 from your Dual-Boot Setup