2
votes

Im trying to implement an empty WPF groupbox as a landing zone for drop event (e.g. Files).

But he following xaml

 <GroupBox Header="Drop Files to convert in here" AllowDrop="True" DragEnter="GroupBox_DragEnter" Drop="GroupBox_Drop" />

just accepts Drops on it's exactly border - and not as wanted on the whole control (space inside the group box). How can I accept Drops for the whole control?

2

2 Answers

6
votes

It is a common "problem" in WPF, just set the background property of the empty control and it should work as expected.

0
votes

The GroupBox is a HeaderContentControl meaning it's content can only hold a single item. If you are wanting to drop multiple files into a GroupBox, I suggest you add a ItemsControl inside of your GroupBox, and when you drop a file add items to that control.

<GroupBox Header="Drop Files to convert in here" AllowDrop="true" DragEnter="ItemsControl_DragEnter" Drop="ItemsControl_Drop">
    <ItemsControl  />
</GroupBox>

I've made a small sample with xaml very similar to this. This should allow drops for the whole control.