views:

46

answers:

1

I'm creating a control which is derived from Panel. When mouse is clicked on one of the children it gets the OnMouseLeftButtonDown overriden method called. When mouse is clicked on the control itself, there is no event. How come?

+2  A: 

If you have no Background set on the Panel, it is not only transparent, but also mouse-transparent.

This is usually set via a TemplateBinding in the default style for your custom control.

kek444
Nice! That fixed it! Maybe you can answer the next question too: why does my new nice white background not extend in the negative coordinates of the control?
Vilx-
Um, well, can you think of a reason why it should paint something outside of its render area?
kek444
Who says the render area is only the positive coordinates? With WPF's abstract device independant coordinate system (and all that jazz) I'd say that render area is whatever is visible. Well, actually I'm not pretty clear on the subject since I'm a WPF-beginner.
Vilx-
A coordinate area is not the same as a render area. Just like you would expect from winforms, clip regions do exist. A difference here would be the rendering of a child element, which may be outside the borders of the Panel (if still within the Window), and is still shown, depending on the overall Z-order of elements.
kek444