Udostępnij za pośrednictwem


FileOpenPickerUI Class

Definition

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

public ref class FileOpenPickerUI sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class FileOpenPickerUI final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class FileOpenPickerUI
Public NotInheritable Class FileOpenPickerUI
Inheritance
Object Platform::Object IInspectable FileOpenPickerUI
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

The File picker provider 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();
}

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 provider 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 the Windows.ApplicationModel.Activation.FileOpenPickerActivatedEventArgs.FileOpenPickerUI property 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

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

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

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

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)

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

CanAddFile(IStorageFile)

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

ContainsFile(String)

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

RemoveFile(String)

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

Events

Closing

Fires when the user closes the file picker.

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.

Applies to

See also