【发布时间】:2016-11-28 22:55:19
【问题描述】:
场景:为 UI 控件启用拖放的 C#/WPF 应用程序。当从 Windows 资源管理器中拖动文件并将其放在 UI 控件上时,会出现一个 MessageBox。
问题:只要 MessageBox 未被点击(通过点击“确定”),Windows 资源管理器就会被冻结并(可能)等待拖放事件返回。
问题:有什么方法可以让 Windows 资源管理器从等待 MessageBox 显示出来? “DragEventArgs”类的“Handled”属性呢?
代码:
private void OnDrop_ButtonOpen(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
MessageBox.Show(files[0]);
}
}
PS:还有其他类似的问题。但是,“过早”返回事件没有解决方案。
【问题讨论】:
标签: c# .net wpf drag-and-drop