I have a stackpanel that contains collection of content. The stackpanel is the dropsource and the content are the dragsources. The purpose is that you can reorder the content on the panel. Currently I have implemented this as an ItemsControl with the Panel being the ItemsPanelTemplate as follows:
<ItemsControl Grid.Row="0" x:Name="ContentItemViewsControl" Margin="10,10,10,10"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" > <idd:DragDropManager.DropTarget> <idd:DropTarget IsDropTarget="True"/> </idd:DragDropManager.DropTarget> </StackPanel> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl>
Because I don't want the content to be stacked right on top of each other, I am adding a bit of margin to each of them. Unfortunately, When you are dragging the content, the place you intuitively want to drop them is in the margins and for some reason, your framework is preventing that and adding a little X in a circle that indicates that you can't drop there, although you are free to drop on to other contents. Is there a reason for this and is there a workaround?
p.s. If it matters, the ItemsControl is bound to an ObservableCollection<Control>
thanks,
-greg
Does anyone from Infragistics have any info on this?
Hi,
I think it's because of hit testing. Please try to set the background of the StackPanelBackground="Transparent"
Regards.PPilev.
Hi PPilev,
Thank you, that solved the problem. I know what Hit Testing is, but can you elaborate a bit on why setting the background to Transparent solved the problem?
thanks
Thank you PPilev, that does explain it very well.
Here's the relevant section:
Although UIElement does not define it, many derived classes implement a Background property (for example Control.Background, Border.Background) or a Fill property (for example Shape.Fill, Glyphs.Fill). These properties use a Brush value. If the Brush is null, the rendering behavior for that area is transparent. An additional behavior is that the area where the brush is applied is not hit testable. (If you want a transparent area that is hit testable, use a Transparent value for a SolidColorBrush.)
Hi Greg,
Have a look at this document. There is a good explanation of this matter.
PPilev.