本文介绍了Caliburn.Micro Drag&在WPF中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 < TextBox Name =Relatorio 
宽度=612Margin =1
AllowDrop =True
cal:Message.Attach =[Event Drop] = [Action DropQ($ eventArgs)];
[Event DragOver] = [Action DragQ($ eventArgs)]>

有什么建议吗?

解决方案

解决方案

 < TextBox Name =Relatorio
Width = 612Margin =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)
{
}


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?

解决方案

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

这篇关于Caliburn.Micro Drag&amp;在WPF中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 11:57