Skip to content

SuggestedStartLocation not working correctly in File/Folder pickers #5836

@Zakariathr22

Description

@Zakariathr22

Describe the bug

When setting the SuggestedStartLocation (e.g., Downloads or Desktop), the picker does not open at the specified location. Instead, it defaults to an Unspecified location.

Steps to reproduce the bug

<StackPanel Spacing="8">
    <Button x:Name="PickSingleFileButton"
            Content="Pick a single file"
            Click="PickSingleFileButton_Click"/>
    <TextBlock x:Name="PickedSingleFileTextBlock" 
               Text="No file picked"/>
</StackPanel>
private async void PickSingleFileButton_Click(object sender, RoutedEventArgs e)
{
    if (sender is Button senderButton && sender is UIElement element)
    {
        //disable the button to avoid double-clicking
        senderButton.IsEnabled = false;

        // Clear previous returned file name, if it exists, between iterations of this scenario
        PickedSingleFileTextBlock.Text = "";

        var picker = new FileOpenPicker(element.XamlRoot.ContentIslandEnvironment.AppWindowId);

        picker.CommitButtonText = "Pick File";

        picker.SuggestedStartLocation = PickerLocationId.Downloads;

        picker.ViewMode = PickerViewMode.List;

        // Show the picker dialog window
        var file = await picker.PickSingleFileAsync();
        PickedSingleFileTextBlock.Text = file != null
            ? "Picked: " + file.Path
            : "No file selected.";

        //re-enable the button
        senderButton.IsEnabled = true;
    }
}

Expected behavior

The picker should open directly in the location provided by SuggestedStartLocation (e.g., open in Downloads when PickerLocationId.Downloads is set).

Screenshots

Image

NuGet package version

Windows App SDK 1.8.0: 1.8.250907003

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 24H2 (26100, June 2025 Update)

IDE

Visual Studio 2022

Additional context

It seems the picker ignores the suggested location and instead opens in the last location from which a file or folder was selected.
For more context, see this PR: microsoft/WinUI-Gallery#2044

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions