FolderPicker.SuggestedStartLocation 属性

定义

获取或设置文件夹选取器查找要呈现给用户的文件夹的初始位置。

public:
 property PickerLocationId SuggestedStartLocation { PickerLocationId get(); void set(PickerLocationId value); };
PickerLocationId SuggestedStartLocation();

void SuggestedStartLocation(PickerLocationId value);
public PickerLocationId SuggestedStartLocation { get; set; }
var pickerLocationId = folderPicker.suggestedStartLocation;
folderPicker.suggestedStartLocation = pickerLocationId;
Public Property SuggestedStartLocation As PickerLocationId

属性值

起始位置的标识符。

示例

文件选取器示例演示如何在文件选取器中显示任何类型的文件。

此简短示例代码演示了在请求的位置打开的 FilePicker。

private async void Button_click(object sender, RoutedEventArgs e)
{
    FileOpenPicker filePicker = new FileOpenPicker();
    filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    filePicker.ViewMode = PickerViewMode.List;
    filePicker.FileTypeFilter.Add(".txt");
    StorageFile file = await filePicker.PickSingleFileAsync();
}

注解

SuggestedStartLocation 并不总是用作文件夹选取器起始位置。 为了为用户提供一致性感,文件夹选取器会记住用户导航到的最后一个位置,并且通常从该位置开始。

适用于