WPF:无法将拖动的数据拖放到ItemsControl上

Pie*_*eed 5 wpf drag-and-drop itemscontrol

我有以下XAML:

<DockPanel x:Name="OverViewContainer" AllowDrop="True">
    <StackPanel Orientation="Horizontal"
                DockPanel.Dock="Bottom"
                HorizontalAlignment="Right">
        <uicommon:Toolbar DataContext="{Binding Commands}" />
    </StackPanel>
    <ItemsControl ItemsSource="{Binding DocumentElements}"
                  ItemTemplate="{DynamicResource DocumentElementsItemTemplate}" />
</DockPanel>
Run Code Online (Sandbox Code Playgroud)

当我将数据拖到此面板上时,鼠标光标显示所有子项都允许删除,但在任何空白空间上,光标显示已禁用删除.如果我设置AllowDrop为false,我不能再删除子项,因此标志DOES有效.我想将数据放入到项目中的边距之间ItemsControl.

有任何想法吗?

use*_*783 11

问题是你的DockPanel没有执行命中测试 - 因为它没有背景.

解决方案?将Background ="Transparent"属性添加到<DockPanel>标记.