问题描述
我已经使用Caliburn.Micro(2.0.1)创建了一个桌面应用程序,现在我需要添加拖放行为,用户将从Windows资源管理器中拖动一个文件,并且需要获取它的路径,但是,我现在搜索了2天,但没有找到有关如何为Caliburn.Micro添加拖放行为的任何示例或说明.我发现了一个问题(将文件拖放到带有Caliburn Micro Framework的WPF ),但无需锻炼.我尝试了很多不同的方式,但现在成功了,我的列表尝试是这样的:
I Have create and desktop application with Caliburn.Micro (2.0.1) and now I need to add a drag&drop behavior, the user will drag a file from the Windows Explorer and I need to get the path of it, however I´m searching for 2 days now and I don´t found any example or explanation of how to add a Drag&Drop behavior for the Caliburn.Micro. I found a question about it (Drag and Drop Files into WPF with Caliburn Micro Framework) but that don´t workout. I have tried a lot of different maners but now sucess, my list try was this:
<TextBox Name="Relatorio"
Width="612" Margin="1"
AllowDrop="True"
cal:Message.Attach="[Event Drop] = [Action DropQ($eventArgs)];
[Event DragOver] = [Action DragQ($eventArgs)]">
有什么建议吗?
推荐答案
解决方案
<TextBox Name="Relatorio"
Width="612" Margin="1"
AllowDrop="True"
cal:Message.Attach="[Event Drop] = [Action FileDropped($eventArgs)];
[Event PreviewDragOver] = [Action FilePreviewDragEnter($eventArgs)]"/>
public void FilePreviewDragEnter(DragEventArgs e)
{
e.Handled = true;
}
public void FileDropped(DragEventArgs e)
{
}
这篇关于Caliburn.Micro Drag& amp; amp; amp; amp; amp; amp;在WPF中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!