简体   繁体   English

使用caliburn micro时,DataGrid拖放不会触发拖放事件

[英]DataGrid drag/drop is not firing drop event when using caliburn micro

I have a datagrid defined in xaml as follow: 我在xaml中定义了一个datagrid,如下所示:

  <DataGrid x:Name="ProcessInputImages" 
              ScrollViewer.HorizontalScrollBarVisibility="Hidden" RowHeaderWidth="0" AutoGenerateColumns="False" IsReadOnly="True"  SelectionMode="Single" SelectionUnit="Cell"
              IsHitTestVisible="True"  AllowDrop="True" cal:Message.Attach="[Event Drop] = [Action ObjectDropped($eventargs)" >

....
 </DataGrid>

and in my code behind, I have: 在后面的代码中,我有:

   public void ObjectDropped(DragEventArgs e)
    {

    }

But the event is not firing when I drop a directory from explorer into it. 但是,当我从资源管理器中将目录拖放到该事件时,该事件并未触发。

Why it is not firing? 为什么不射击?

The problem was that xaml was wrong: 问题是xaml是错误的:

the correct syntax is: 正确的语法是:

 <DataGrid x:Name="ProcessInputImages" 
          ScrollViewer.HorizontalScrollBarVisibility="Hidden" RowHeaderWidth="0" AutoGenerateColumns="False" IsReadOnly="True"  SelectionMode="Single" SelectionUnit="Cell"
          IsHitTestVisible="True"  AllowDrop="True" cal:Message.Attach="[Event Drop] = [Action ObjectDropped($eventargs)]" >

.... ....

note ] at the end of cal:Message.Attach="[Event Drop] = [Action ObjectDropped($eventargs)] which was missing. 在cal:Message.Attach =“ [Event Drop] = [Action ObjectDropped($ eventargs)]”末尾缺少的注释[]。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM