Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: Can't drop dragged data onto an ItemsControl

I have the following 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>

When I drag data onto this panel, the mouse cursor shows a drop is allowed on all the child items, but on any empty space, the cursor shows that dropping is disabled. If I set AllowDrop to false, I can't drop onto the child items anymore, so the flag DOES have an effect. I would like to drop data into the margins between the items in the ItemsControl.

Any ideas?

like image 850
Pieter Breed Avatar asked Oct 21 '09 05:10

Pieter Breed


1 Answers

The problem is that your DockPanel is not performing hit testing - since it has no background.

The solution? Add a Background="Transparent" attribute to the <DockPanel> tag.

like image 58
user200783 Avatar answered Sep 19 '22 18:09

user200783