PreferenceStartLocation vs ActualStartLocation

There is no such thing as ActualStartLocation in UWP when you set the folder to open FileOpenPicker and that is the reason for my question. There is a RecommendedStartLocation , but Microsoft's site clearly states:

"The recommended placement point is not always used as the starting location for the file collector. To give the user a sense of consistency, the file collector remembers the last location the user navigated to and will usually launch there."

The recommended StartLocation object remembers where you were and continues to open the same folder every time. As an example, add this code to the button click event in your UWP project:

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null) {
    TextBlock1.Text = "Selected Photo: " + file.Name;
} else {
    TextBlock1.Text = "Operation cancelled.";
}

      

Now run the program and select an image.

Close the program to change the code to use MusicLibrary instead of PicturesLibrary.

Run the program again and when you press the button, you will be returned to PicturesLibrary, even if you asked to watch the music.

Is there a way to override this and force the location where the file picker will start? (ie: ActualStartLocation)

I am trying to create an application where the user selects an image and a music file and it would be nice if the image collector always opens in the pictures folder and if the music program always opens in the music folder.

+3


source to share


1 answer


As you know, this is by design.

"The recommended placement point is not always used as the starting location for the file collector. To give the user a sense of consistency, the file collector remembers the last location the user navigated to and will usually run there."



When you use FileOpenPicker

to select a file, PickerHost.exe

breakfast will be. PickerHost

- system application. And it will record the last location you visited. You cannot change the entry in your application. There is currently no such property "ActualStartLocation" to achieve what you want. If you need this function, you can ask UserVoice .

+2


source







All Articles