Aasish
Aasish

Reputation: 377

UWP FolderPicker Bring to Front of opening app

I have UWP code for performing some tasks, after completion task FolderPicker is used to select location for file save by user. Because task completion requires some time user may switch my app to another app/window when user come back to my app the FolderPicker opens but on back of application(which is invisible) in that case user may not notice Folder picker. Is there any way to bring FolderPicker in front of opening app? Please help, Thanks.


Upvotes: 0

Views: 339

Answers (1)

A. Milto
A. Milto

Reputation: 2383

If you want to bring the file picker dialog or the whole app to the top like you could in WinForms or WPF, then there's no exact equivalent of that in UWP.

Compact Overlay mode is as close as you can get. It's a way of displaying a compact view of an app on top of other windows, introduced in Creators Update: Compact Overlay mode - App in top right corner

You could go to the compact overlay mode (this would show your app on top of the others), display the file picker, get back to normal mode:

if (ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay))
    await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay);

var file = await picker.PickSingleFileAsync();

await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);

The only problem is that when in compact overlay mode, the view is going to shrink, but you can solve this using a dedicated view for showing in compact overlay mode (see this article) from which you'll call the file picker.

This should answer your question, but to tell the truth, a dialog that jumps on top of other windows seems to be an example of bad UX. You're better off either displaying the file picker beforehand (while the user is in the app) or notifying him later with a toast, that would lead to your app when clicked on (this would be more polite and a user would have a chance to disable notifications in the action center when he or she doesn't want to get distracted).

Upvotes: 0

Related Questions