FileOpenPickerUI 類別

定義

如果您的應用程式提供檔案開啟選擇器合約,則用來與檔案選擇器互動。

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
繼承
Object Platform::Object IInspectable FileOpenPickerUI
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

檔案選擇器提供者範例示範如何回應FileOpenPicker啟動的事件。

// 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();
}

針對 C#, args 包含 FileOpenPickerActivatedEventArgs 物件。 此外,位於 OnFileOpenPickerActivated App.xaml.cs 檔案中,而 Activate 方法位於 檔案選擇器提供者範例的 FileOpenPickerPage.xaml.cs 檔案中。

備註

如果您的應用程式參與檔案開啟選擇器合約,您可以在處理 FileOpenPicker 啟動事件時,使用 FileOpenPickerUI 屬性擷取此物件。

使用 Windows.ApplicationModel.Activation.FileOpenPickerActivatedEventArgs.FileOpenPickerUI 屬性來存取 FileOpenPickerUI

閱讀使用 選擇器在開啟檔案和資料夾中提供檔案的 UX 指導方針,瞭解如何在使用者透過檔案選擇器存取檔案時,為使用者建立良好的體驗。

屬性

AllowedFileTypes

取得使用者可以選擇的檔案類型清單 (副檔名) 。

SelectionMode

取得列舉值,指出檔案選擇器目前是否限制選取單一檔案,或是否可以選取多個檔案。

SettingsIdentifier

取得檔案選擇器目前內容的識別碼。

Title

取得或設定要在檔案選擇器 UI 中顯示的標題,識別檔案選擇器向使用者顯示的位置。

方法

AddFile(String, IStorageFile)

將指定的檔案新增至使用者選擇的檔案清單。

CanAddFile(IStorageFile)

指出是否可以將指定的檔案新增至使用者選擇的檔案清單。

ContainsFile(String)

判斷指定的檔案是否位於使用者選擇的檔案清單中。

RemoveFile(String)

從使用者選擇的檔案清單中移除指定的檔案。

事件

Closing

當使用者關閉檔案選擇器時引發。

FileRemoved

注意

FileRemoved 事件已被取代,不應使用。

當使用者從使用者選擇的檔案清單中移除檔案時引發,前提是提供檔案的應用程式已新增該檔案。

適用於

另請參閱