FileOpenPickerUI FileOpenPickerUI FileOpenPickerUI FileOpenPickerUI FileOpenPickerUI Class

Definition

Used to interact with the file picker if your app provides files with the File Open Picker contract.

public : sealed class FileOpenPickerUI : IFileOpenPickerUI
struct winrt::Windows::Storage::Pickers::Provider::FileOpenPickerUI : IFileOpenPickerUI
public sealed class FileOpenPickerUI : IFileOpenPickerUI
Public NotInheritable Class FileOpenPickerUI Implements IFileOpenPickerUI
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The File picker sample demonstrates how to respond to a fileOpenPicker activated event.


// File open picker activated event handler
protected override void OnFileOpenPickerActivated(FileOpenPickerActivatedEventArgs args)
{
    var FileOpenPickerPage = new SDKTemplate.FileOpenPickerPage();
    FileOpenPickerPage.Activate(args);
}

// Overloaded method to respond to fileOpenPicker events
public void Activate(FileOpenPickerActivatedEventArgs args)
{
    // Perform tasks to prepare your app to display its file picker page

    // Get file picker UI
    fileOpenPickerUI = args.FileOpenPickerUI;

    Window.Current.Content = this;
    this.OnNavigatedTo(null);
    Window.Current.Activate();
}


// File open picker activated event handler
function activated(eventObject) {
    // Identify whether app is launched for fileOpenPicker
    if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.fileOpenPicker) {
        // Perform tasks to prepare your app to display its file picker page

        // Get file picker UI
        fileOpenPickerUI = eventObject.detail.fileOpenPickerUI;

        eventObject.setPromise(WinJS.UI.processAll().then(function () {
            // Navigate to either the first scenario or to the last running scenario
            // before suspension or termination.
            var url = scenarios[0].url;
            return WinJS.Navigation.navigate(url, fileOpenPickerUI);
        }));
    }
}

// Register the activated event handler
WinJS.Application.addEventListener("activated", activated, false);

For JavaScript, eventObject contains a webUIFileOpenPickerActivatedEventArgs object.

For C#, args contains a FileOpenPickerActivatedEventArgs object. Additionally, the OnFileOpenPickerActivated is in the App.xaml.cs file and the Activate method is in the FileOpenPickerPage.xaml.cs file of the File picker sample.

Remarks

If your app participates in the File Open Picker contract, you can retrieve this object using a FileOpenPickerUI property while you handle a fileOpenPicker activated event.

Use one of the following properties to access a FileOpenPickerUI:

Learn about creating a good experience for users when they access your files through the file picker by reading the UX guidelines for providing files in Open files and folders with a picker.

Properties

AllowedFileTypes AllowedFileTypes AllowedFileTypes AllowedFileTypes AllowedFileTypes

Gets a list of file types (extensions) that the user can choose.

SelectionMode SelectionMode SelectionMode SelectionMode SelectionMode

Gets an enumeration value that indicates whether the file picker currently limits selection to single files, or if multiple files can be selected.

SettingsIdentifier SettingsIdentifier SettingsIdentifier SettingsIdentifier SettingsIdentifier

Gets an identifier for the current context of the file picker.

Title Title Title Title Title

Gets or sets a title to display in the file picker UI that identifies the location that the file picker is displaying to the user.

Methods

AddFile(String, IStorageFile) AddFile(String, IStorageFile) AddFile(String, IStorageFile) AddFile(String, IStorageFile) AddFile(String, IStorageFile)

Adds the specified file to the list of files that the user has chosen.

CanAddFile(IStorageFile) CanAddFile(IStorageFile) CanAddFile(IStorageFile) CanAddFile(IStorageFile) CanAddFile(IStorageFile)

Indicates whether the specified file can be added to the list of files the user has chosen.

ContainsFile(String) ContainsFile(String) ContainsFile(String) ContainsFile(String) ContainsFile(String)

Determines whether the specified file is in the list of files that the user has chosen.

RemoveFile(String) RemoveFile(String) RemoveFile(String) RemoveFile(String) RemoveFile(String)

Removes the specified file from the list of files the user has chosen.

Events

Closing Closing Closing Closing Closing

Fires when the user closes the file picker.

FileRemoved FileRemoved FileRemoved FileRemoved FileRemoved

Note

The fileremoved event is deprecated and should not be used.

Fires when the user removes a file from the list of files that the user has chosen if that file was added by the app that is providing files.

See Also