Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a control visible to hit-testing but transparent to drag&drop

Tags:

c#

wpf

I have an ItemsControl that displays items as polylines and has a transparent background. I want to make this control invisible as a drop-target (so that the control underneath it can receive drag-drop events), but I do want to make it visible for hit-testing so that I can click on the polylines and perform operations on them.

I found the IsHitTestVisible property. However it enables or disables both drag-drop and hit-testing. Is there any way to make the control be "invisible" just as a possible drop target, but leaving it visible for hit-testing and mouse events?

Thanks.

Update

I eventually found out that an ItemsControl, even if its background is transparent, somehow hides the elements underneath it from mouse events. So the problem is not with drag-drop. Do you know how can I make it be really transparent and allow the items underneath it have mouse events?

like image 541
Alex Shtof Avatar asked Sep 16 '25 10:09

Alex Shtof


1 Answers

You would need to set it's Background to null, or {x:Null} in XAML. This works like transparent, but doesn't allow that area to be hit-test as part of the control.

like image 69
CodeNaked Avatar answered Sep 18 '25 08:09

CodeNaked