Caliburn.Micro 在 WPF 中拖放文件

Gui*_*ais 2 wpf drag-and-drop file caliburn.micro

我已经使用 Caliburn.Micro (2.0.1) 创建和桌面应用程序,现在我需要添加一个拖放行为,用户将从 Windows 资源管理器中拖动一个文件,我需要获取它的路径,但是我正在搜索2 天了,我没有找到任何关于如何为 Caliburn.Micro 添加拖放行为的示例或解释。我发现了一个关于它的问题(使用 Caliburn Micro Framework 将文件拖放到 WPF 中),但这并没有锻炼。我尝试了很多不同的方法,但现在成功了,我的列表尝试是这样的:

<TextBox Name="Relatorio"
         Width="612" Margin="1" 
         AllowDrop="True"
         cal:Message.Attach="[Event Drop] = [Action DropQ($eventArgs)];
                             [Event DragOver] = [Action DragQ($eventArgs)]">
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

小智 5

解决方案,

 <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)
    {
    }
Run Code Online (Sandbox Code Playgroud)