为什么我无法将文件从资源管理器拖放到 FlowDocumentReader 以及如何修复它?
我正在尝试实现一项功能,允许用户将文件拖到要在 FlowDocumentReader 中打开的应用程序中。
我的问题是,虽然我在 FlowDocumentReader 上设置了 AllowDrop=true,但光标不会更改为“放置到此处”图标,而是更改为“不允许放置”图标。 这种情况仅发生在 FlowDocumentReader 上,UI 的所有其他部分(窗口本身、其他控件)都按预期工作。 FlowDocumentReader 实际上接收事件,并且可以处理放置,但用户没有视觉指示表明他可以在此处释放鼠标。
我也无法通过设置 Cursor=Cursors.None 来隐藏“不允许放置”光标
I'm trying to implement a piece of functionality that will let the user to drag files into an application to be opened in the FlowDocumentReader.
My problem is that is though I have AllowDrop=true on the FlowDocumentReader, the cursor does not change to the "drop here" icon but changes instead to "drop is not allowed" icon.
This happens only to the FlowDocumentReader, all other parts og the UI (window itself, other controls) work as expected. The FlowDocumentReader actually receives the events, and it is possible to handle the drop, but the user does not have a visual indication that he can release the mouse here.
I also cannot hide the "drop is not allowed" cursor by setting Cursor=Cursors.None
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
需要处理 FlowDocument 中的 DragOver 事件以允许放置在此处。
xaml:
背后代码:
Need to handle DragOver event in FlowDocument to allow dropping here.
xaml:
code behind:
我找不到任何直接的方法来解决这个问题,所以这就是我最终得到的结果:
当网格接收到 Drop 或 DragLeave 事件时,其可见性将转回 Collapsed 以允许 FlowDocument 接收鼠标事件
I couldn't find any direct way to solve this, so here is what I have ended up with:
When grid receives Drop or DragLeave events, its visibility is turned back to Collapsed to allow the FlowDocument receive mouse events