diff --git a/src/Files.App/Actions/FileSystem/DeleteItemAction.cs b/src/Files.App/Actions/FileSystem/DeleteItemAction.cs index 34eb35490564..f333a472ad3b 100644 --- a/src/Files.App/Actions/FileSystem/DeleteItemAction.cs +++ b/src/Files.App/Actions/FileSystem/DeleteItemAction.cs @@ -25,7 +25,7 @@ internal class DeleteItemAction : ObservableObject, IAction public HotKey HotKey { get; } = new(VirtualKey.Delete); - public bool IsExecutable => context.PageType is not ContentPageTypes.SearchResults && context.HasSelection; + public bool IsExecutable => context.HasSelection; public DeleteItemAction() { @@ -38,19 +38,16 @@ public async Task ExecuteAsync() return; var items = context.SelectedItems.Select(item => StorageHelpers.FromPathAndType(item.ItemPath, - item.PrimaryItemAttribute == StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory)); + item.PrimaryItemAttribute is StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory)); + await context.ShellPage.FilesystemHelpers.DeleteItemsAsync(items, settings.DeleteConfirmationPolicy, true, true); + await context.ShellPage.FilesystemViewModel.ApplyFilesAndFoldersChangesAsync(); } public void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { - switch (e.PropertyName) - { - case nameof(IContentPageContext.PageType): - case nameof(IContentPageContext.HasSelection): - OnPropertyChanged(nameof(IsExecutable)); - break; - } + if (e.PropertyName is nameof(IContentPageContext.HasSelection)) + OnPropertyChanged(nameof(IsExecutable)); } } }