private void TreeFavorites_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { var selected = TreeFavorites.SelectedItem as FavoriteItem; if (selected == null) { return; } var mousePos = e.GetPosition(null); var diff = startPoint - mousePos; if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance) { var treeView = sender as TreeView; var treeViewItem = WindowUtilities.FindAnchestor <TreeViewItem>((DependencyObject)e.OriginalSource); if (treeView == null || treeViewItem == null) { return; } var dragData = new DataObject(DataFormats.UnicodeText, selected.File + "|" + selected.Title); DragDrop.DoDragDrop(treeViewItem, dragData, DragDropEffects.Copy); IsDragging = true; } } }
private void TreeFolderBrowser_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { var selected = TreeFolderBrowser.SelectedItem as PathItem; // Only allow the items to be dragged var src = e.OriginalSource as TextBlock; if (src == null) { return; } // only drag image files if (selected == null || selected.IsFolder) { return; } var mousePos = e.GetPosition(null); var diff = startPoint - mousePos; if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance) { var treeView = sender as TreeView; var treeViewItem = WindowUtilities.FindAnchestor <TreeViewItem>((DependencyObject)e.OriginalSource); if (treeView == null || treeViewItem == null) { return; } var files = new[] { selected.FullPath }; var dragData = new DataObject(DataFormats.FileDrop, files); DragDrop.DoDragDrop(treeViewItem, dragData, DragDropEffects.Copy); } } }