public void DropImages(DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var pathes = e.Data.GetData(DataFormats.FileDrop, true) as string[]; if (pathes == null) { return; } Task.Factory.StartNew(() => { var viewModels = new List <ImageViewModel>(); foreach (var path in pathes) { var attributes = File.GetAttributes(path); bool isFolder = (attributes & FileAttributes.Directory) == FileAttributes.Directory; if (isFolder) { var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(ImageFormatHelper.IsImage); var imageViewModels = files.Select(p => new ImageViewModel { Path = p }); viewModels.AddRange(imageViewModels); } else { if (ImageFormatHelper.IsImage(path)) { viewModels.Add(new ImageViewModel { Path = path }); } } Application.Current.Dispatcher.Invoke((Action)(() => ImageCollection.AddRange(viewModels))); } }); } }