diff --git a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs
index 9bf5ed995848..e13d792a8f20 100644
--- a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs
+++ b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs
@@ -55,7 +55,7 @@ public static DynamicDialog GetFor_ShortcutNotFound(string targetPath)
return dialog;
}
- public static DynamicDialog GetFor_CreateItemDialog(string itemType)
+ public static DynamicDialog GetFor_CreateItemDialog(string itemType, string? itemName)
{
DynamicDialog? dialog = null;
TextBox inputText = new()
@@ -95,14 +95,24 @@ public static DynamicDialog GetFor_CreateItemDialog(string itemType)
inputText.Loaded += (s, e) =>
{
- // dispatching to the ui thread fixes an issue where the primary dialog button would steal focus
- _ = inputText.DispatcherQueue.EnqueueOrInvokeAsync(() => inputText.Focus(FocusState.Programmatic));
+ // Dispatching to the UI thread fixes an issue where the primary dialog button would steal focus
+ _ = inputText.DispatcherQueue.EnqueueOrInvokeAsync(() =>
+ {
+ // Prefill text box with default name #17845
+ if (itemType.Equals("Folder", StringComparison.OrdinalIgnoreCase))
+ inputText.Text = Strings.NewFolder.GetLocalizedResource();
+ else if (itemName is not null)
+ inputText.Text = string.Format(Strings.CreateNewFile.GetLocalizedResource(), itemName);
+
+ inputText.Focus(FocusState.Programmatic);
+ inputText.SelectAll();
+ });
};
dialog = new DynamicDialog(new DynamicDialogViewModel()
{
TitleText = string.Format(Strings.CreateNewItemTitle.GetLocalizedResource(), itemType),
- SubtitleText = null,
+ SubtitleText = Strings.EnterAnItemName.GetLocalizedResource(),
DisplayControl = new Grid()
{
MinWidth = 300d,
diff --git a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs
index 74ec1ccb8330..0d819b7b109c 100644
--- a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs
+++ b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs
@@ -107,7 +107,7 @@ public static async Task CreateFileFromDialogResultTypeAsync(AddItemDialogItemTy
string? userInput = null;
if (itemType != AddItemDialogItemType.File || itemInfo?.Command is null)
{
- DynamicDialog dialog = DynamicDialogFactory.GetFor_CreateItemDialog(itemType.ToString().GetLocalizedResource().ToLower());
+ DynamicDialog dialog = DynamicDialogFactory.GetFor_CreateItemDialog(itemType.ToString().GetLocalizedResource().ToLower(), itemInfo?.Name);
await dialog.TryShowAsync(); // Show rename dialog
if (dialog.DynamicResult != DynamicDialogResult.Primary)
diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw
index a94b1f51aef8..38a948eaa110 100644
--- a/src/Files.App/Strings/en-US/Resources.resw
+++ b/src/Files.App/Strings/en-US/Resources.resw
@@ -4347,4 +4347,7 @@
Only in Columns View
+
+ New {0}
+
\ No newline at end of file