tags:

views:

12

answers:

1

ok, I got the several shapes in my custom FrameworkElement to allow for hit testing selection. Next comes the task of deselecting all shapes if the user clicks on a blank area. This doesn't work by default because the FrameworkElement doesn't fire a mousedown event if you click on a "blank" area.

Do people solve this by putting a background rectangle as the first drawingvisual in their frameworkelements (that will accept clicks, but will be treated differently than clicking on the foreground objects), or do they handle the "empty" mousedown events in the class that constructs the FrameworkElement (which in my case is a Viewmodel in an MVVM setup)? Or a third way I'm not considering?

thank you

A: 

Try setting the background to transparant and you most likely will get mouse down events.

Instead of deriving from FrameworkElement, derive your control from Control class. The Control class has the Background property which you will set to transparant to get mouse down events. See below link for comments about deriving directly from FrameworkElement:

http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.aspx

Wallstreet Programmer
there is no background to set- my FrameworkElement is comprised of little shapes, each comprised of a DrawingVisual. Are you suggesting I add a transparent rectangle to the DrawingVisual collection?
taglius