using System.Windows; using System.Windows.Controls; using System.Windows.Input; namespace WPF路由事件_8_鼠标拖拽; /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void LabelDrop1_OnDrop(object sender, DragEventArgs e) { e.Effects = e.Data.GetDataPresent(DataFormats.Text) ? DragDropEffects.Copy : DragDropEffects.None; } private void LabelDrop1_OnMouseDown(object sender, MouseButtonEventArgs e) { var label = (Label)sender; DragDrop.DoDragDrop(label, LabelDrop1.Content, DragDropEffects.Copy); } }