Caliburn.Micro Drag & Drop of a File in a WPF

2019-07-27 07:54发布

问题:

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)]">

Any suggestions at all?

回答1:

Solution,

 <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)
    {
    }