diff --git a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs index c4fa685b7bae..984d49364705 100644 --- a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs +++ b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs @@ -101,6 +101,14 @@ public async Task DragOverAsync(DragEventArgs e) return; } + // Check if ShellViewModel is initialized to prevent race condition + if (_associatedInstance.ShellViewModel is null) + { + e.AcceptedOperation = DataPackageOperation.None; + deferral.Complete(); + return; + } + if (FilesystemHelpers.HasDraggedStorageItems(e.DataView)) { e.Handled = true; @@ -207,6 +215,13 @@ public async Task DropAsync(DragEventArgs e) } } + // Check if ShellViewModel is initialized to prevent race condition + if (_associatedInstance.ShellViewModel is null) + { + e.AcceptedOperation = DataPackageOperation.None; + return; + } + var deferral = e.GetDeferral(); try {