diff --git a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs index 143db003cd7..c92eaf3e0e2 100644 --- a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs +++ b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs @@ -222,6 +222,7 @@ List GetFilters() { Title = "Open file", FileTypeFilter = GetFileTypes(), + SuggestedFileName = "FileName", SuggestedStartLocation = lastSelectedDirectory, AllowMultiple = openMultiple.IsChecked == true }); @@ -264,6 +265,7 @@ List GetFilters() { Title = "Folder file", SuggestedStartLocation = lastSelectedDirectory, + SuggestedFileName = "FileName", AllowMultiple = openMultiple.IsChecked == true }); diff --git a/src/Avalonia.Base/Platform/Storage/FilePickerSaveOptions.cs b/src/Avalonia.Base/Platform/Storage/FilePickerSaveOptions.cs index fa4fccd47a4..267ba59c71b 100644 --- a/src/Avalonia.Base/Platform/Storage/FilePickerSaveOptions.cs +++ b/src/Avalonia.Base/Platform/Storage/FilePickerSaveOptions.cs @@ -7,11 +7,6 @@ namespace Avalonia.Platform.Storage; /// public class FilePickerSaveOptions : PickerOptions { - /// - /// Gets or sets the file name that the file save picker suggests to the user. - /// - public string? SuggestedFileName { get; set; } - /// /// Gets or sets the default extension to be used to save the file. /// diff --git a/src/Avalonia.Base/Platform/Storage/PickerOptions.cs b/src/Avalonia.Base/Platform/Storage/PickerOptions.cs index 07f99f32c86..4fcc85a07aa 100644 --- a/src/Avalonia.Base/Platform/Storage/PickerOptions.cs +++ b/src/Avalonia.Base/Platform/Storage/PickerOptions.cs @@ -1,4 +1,7 @@ -namespace Avalonia.Platform.Storage; +using System.Collections.Generic; +using Avalonia.Platform.Storage; + +namespace Avalonia.Platform.Storage; /// /// Common options for , and methods. @@ -16,4 +19,9 @@ public class PickerOptions /// or . /// public IStorageFolder? SuggestedStartLocation { get; set; } + + /// + /// Gets or sets the file name that the file picker suggests to the user. + /// + public string? SuggestedFileName { get; set; } } diff --git a/src/Avalonia.Native/SystemDialogs.cs b/src/Avalonia.Native/SystemDialogs.cs index 9106644dc09..76bf2d3bfa3 100644 --- a/src/Avalonia.Native/SystemDialogs.cs +++ b/src/Avalonia.Native/SystemDialogs.cs @@ -41,7 +41,7 @@ public override async Task> OpenFilePickerAsync(File options.AllowMultiple.AsComBool(), options.Title ?? string.Empty, suggestedDirectory, - string.Empty, + options.SuggestedFileName ?? string.Empty, fileTypes); var result = await events.Task.ConfigureAwait(false); diff --git a/src/Windows/Avalonia.Win32/Win32StorageProvider.cs b/src/Windows/Avalonia.Win32/Win32StorageProvider.cs index 56ba96fcf6d..11ae0d6c0c3 100644 --- a/src/Windows/Avalonia.Win32/Win32StorageProvider.cs +++ b/src/Windows/Avalonia.Win32/Win32StorageProvider.cs @@ -39,7 +39,7 @@ public override async Task> OpenFolderPickerAsync( return await ShowFilePicker( true, true, options.AllowMultiple, false, - options.Title, null, options.SuggestedStartLocation, null, null, + options.Title, options.SuggestedFileName, options.SuggestedStartLocation, null, null, f => new BclStorageFolder(new DirectoryInfo(f))) .ConfigureAwait(false); } @@ -49,7 +49,7 @@ public override async Task> OpenFilePickerAsync(File return await ShowFilePicker( true, false, options.AllowMultiple, false, - options.Title, null, options.SuggestedStartLocation, + options.Title, options.SuggestedFileName, options.SuggestedStartLocation, null, options.FileTypeFilter, f => new BclStorageFile(new FileInfo(f))) .ConfigureAwait(false);