我知道这个问题已经有很多答案了,但是我仍然无法使它工作。我在应用程序的每个级别上启用了AllowDrop,并尝试在每个控件上捕获DragEnter和Drop事件,但都没有成功。我可以在应用程序内部拖放项目,但是每当我尝试从Windows资源管理器或桌面等地方拖入东西时,它就会给我一个“不可”图标。任何想法我可能做错了什么吗?
以下是我正在做的示例。仍然没有显示移动光标,并且无法触发MainWindow_DragEnter函数。
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(MainWindow_DragEnter);
}
void MainWindow_DragEnter(object sender, DragEventArgs e)
{
e.Effects = DragDropEffects.Move;
}
}
}