C# 拖放;数据网格(WPF)中的Drop不工作

C# 拖放;数据网格(WPF)中的Drop不工作,c#,excel,datagrid,drag-and-drop,C#,Excel,Datagrid,Drag And Drop,在我的Excel插件中,我有一个WPF窗口。在windows内部,有一个usercontrol,它的顶部部分有一个datagrid(称为datagrid1)。窗口的下部有另一个usercontrol,它包含一个datagrid(称为datagrid2)。 我想将行从datagrid1拖到datagrid2 <dg:DataGrid Grid.Row="1" x:Name="basketDG" Margin="5 0 5 0" Background="White"

在我的Excel插件中,我有一个WPF窗口。在windows内部,有一个usercontrol,它的顶部部分有一个datagrid(称为datagrid1)。窗口的下部有另一个usercontrol,它包含一个datagrid(称为datagrid2)。 我想将行从datagrid1拖到datagrid2

<dg:DataGrid Grid.Row="1" x:Name="basketDG" Margin="5 0 5 0" Background="White"
              AutoGenerateColumns="False" 
              Style="{StaticResource DataGridStyle}"
              ItemsSource="{Binding MyItems, Mode=OneWay}" 
              SelectedItem="{Binding SelectedRelComplete}" 
              SelectionChanged="BasketDgSelectionChanged"                  
              Drop="DataGridDrop" 
              DragEnter="DataGridDragEnter" 
             >

    <Style x:Key="DataGridRowStyle"  TargetType="{x:Type dg:DataGridRow}">
        <Setter Property="AllowDrop" Value="True" />         
    </Style>
    <Style x:Key="DataGridStyle" TargetType="{x:Type dg:DataGrid}">
        <Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle}" />
    </Style>
对于datagrid1

<toolkit:DataGrid 
              Style="{StaticResource DataGridStyle}"
              SelectionMode="Extended"
              ItemsSource="{Binding Relations}"
              SelectedItem="{Binding ListSelection}"
              MouseDoubleClick="dg_MouseDoubleClick"
              DragEnter="DataGrid_CheckDropTarget"
              DragLeave="DataGrid_CheckDropTarget"
              DragOver="DataGrid_CheckDropTarget"
              PreviewMouseLeftButtonDown="DG_PreviewMouseLeftButtonDown" 
                  ContextMenuOpening="dg_ContextMenuOpening"
              PreviewMouseMove="DG_MouseMove" BorderBrush="LightGray">

对于datagrid2

<dg:DataGrid Grid.Row="1" x:Name="basketDG" Margin="5 0 5 0" Background="White"
              AutoGenerateColumns="False" 
              Style="{StaticResource DataGridStyle}"
              ItemsSource="{Binding MyItems, Mode=OneWay}" 
              SelectedItem="{Binding SelectedRelComplete}" 
              SelectionChanged="BasketDgSelectionChanged"                  
              Drop="DataGridDrop" 
              DragEnter="DataGridDragEnter" 
             >

    <Style x:Key="DataGridRowStyle"  TargetType="{x:Type dg:DataGridRow}">
        <Setter Property="AllowDrop" Value="True" />         
    </Style>
    <Style x:Key="DataGridStyle" TargetType="{x:Type dg:DataGrid}">
        <Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle}" />
    </Style>

但事件DragEnter(在datagrid2上)根本不会被触发


我在这里错过了什么?

经过几天的搜索和挣扎,我终于找到了一些东西

这是WPF中的一个错误,在非默认域中执行WPF应用程序时,拖放将不起作用。 看

非常感谢塞缪尔·杰克解决了这个问题,并在他的博客中提出了解决办法
@经过几天的谷歌搜索和挣扎,我终于找到了一些东西

这是WPF中的一个错误,在非默认域中执行WPF应用程序时,拖放将不起作用。 看

非常感谢塞缪尔·杰克解决了这个问题,并在他的博客中提出了解决办法 @