在我的Excel AddIn中,我有一個WPF窗口。在窗口內部,有一個用戶控件,在頂部部分有一個數據網格(稱之爲datagrid1)。窗口的下半部分有另一個用戶控件,它包含一個數據網格(稱之爲datagrid2)。 我想從DataGrid1中拖行其拖放到datagrid2Drag&Drop在DataGrid(WPF)中不起作用
爲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)不會被觸發的。
我在這裏錯過了什麼?