While creating WPF demonstration code, I decided to use the classic DoDrag() method, to perform drag and drop functions. When dropping objects on both a Canvas and Border object, DoDrag() unexpectedly and consistently returned Effects.None.
The solution was easy: the Canvas and Border objects had no Fill. DoDrag's hit test was failing, because there was no physical rendering of the Canvas or Border at the mouse position! The object must be filled, to return a positive hit test. Using the "Transparent" brush or a solid color with 00 alpha works, too.
Note, borders are considered filled areas, and return a positive hit. You can use this to your advantage, but I'm not sure why you would ever drag and drop something on a border, unless it is very thick. You could use a border as a drop mask, to return different Effects result, over certain areas of an object.
No comments:
Post a Comment
Please provide details, when posting technical comments. If you find an error in sample code or have found bad information/misinformation in a post, please e-mail me details, so I can make corrections as quickly as possible.