C# 我已经在datagrid中启用了拖放功能,但没有触发事件处理程序

C# 我已经在datagrid中启用了拖放功能,但没有触发事件处理程序,c#,wpf,C#,Wpf,我有一个带有datagrid的用户控件。我想启用拖放,从文件资源管理器拖放文件。我正在使用MVVM 我的代码是: <DataGrid Name="dgdFicheros" Grid.Row="1" AllowDrop="True" ItemsSource="{Binding Ficheros}" SelectedItem="{Binding

我有一个带有datagrid的用户控件。我想启用拖放,从文件资源管理器拖放文件。我正在使用MVVM

我的代码是:

<DataGrid Name="dgdFicheros" Grid.Row="1"
          AllowDrop="True"
          ItemsSource="{Binding Ficheros}"
          SelectedItem="{Binding FicherosSelectedItem}"
          dp:DataGridSelectedItemsDependencyProperty.SelectedItems="{Binding FicherosSelectedItems}"
          Style="{StaticResource DataGridDefault}">
    <DataGrid.Columns>
        <DataGridTextColumn Header="ID Fichero" Binding="{Binding IDFichero}"/>
        <DataGridTextColumn Header="Nombre" Binding="{Binding Nombre}"/>
    </DataGrid.Columns>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Drop">
            <i:InvokeCommandAction Command="{Binding FicherosDropCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</DataGrid>


private RelayCommand<DragEventArgs> _ficherosDropCommand;
public RelayCommand<DragEventArgs> FicherosDropCommand
{
    get { return _ficherosDropCommand ?? (_ficherosDropCommand = new RelayCommand<DragEventArgs>(OnFicherosDrop, param => true)); }
}

private void OnFicherosDrop(DragEventArgs e)
{
    string dummy = "";
    dummy = dummy + " ";

    _dialogos.AbrirDialogoAceptar("Funciona.");
}

专用中继命令_ficherosDropCommand;
公共中继命令FICHERSDROPCOMMAND
{
获取{return{ficherosDropCommand???({ficherosDropCommand=newrelaycommand(OnFicherosDrop,param=>true));}
}
私有void OnFicherosDrop(DragEventArgs e)
{
字符串dummy=“”;
虚拟=虚拟+“”;
_dialogos.abirdialogoaceptar(“功能”);
}
但事件处理程序不会被激发。但是,鼠标指针已更改为拖动操作的图标,因此似乎已正确启用,但不起作用


谢谢

您应该将命令的类型从
RelayCommand
更改为
RelayCommand
,因为在执行命令时没有实例化
DragEventArgs

如果将类型更改为
RelayCommand
是否有效?
DataGrid
DataContext
是什么?太好了,thaks。