views:

299

answers:

1

When i don't set background of my panel i can not get mouse events on that. why this behaviour? I am able to get mouse events on panel by setting Background to Transparent which is null by default. Whats the difference between Background null and Transparent?

+4  A: 

When Background=null it doesn't issue any drawing command to MILCore when rendering, and it doesn't count the control's entire area in hit testing.

When Background=Transparent, it issues an ordinary drawing command to MILCore when rendering, and it does control the entire area in hit testing.

Brushes.Transparent is really an ordinary brush with it's alpha (opacity) channel set to zero. Because of this, it acts like an ordinary color in most situations. If the background were an ordinary color, mouse clicks would be detected, so they are also detected for Brushes.Transparent.

That said, there are a few places where code detects Brushes.Transparent and optimizes it away by omitting a drawing command entirely. For example this happens for window transparency's interaction with the operatings system: The OS is not informed that any areas painted with Brushes.Transparent are part of the application, so clicking on it does nothing. This is done by special-casing Brushes.Transparent for this purpose.

Ray Burns
does all rendering performed on MILCore?
viky
MILCore is Microsoft's name for the native (non-managed) portion of WPF that maintains render data, marshals it over channels (for remoting situations) and calls Direct3D to do the actual rendering. Most accurately, it is your video card's driver and hardware that does the actual rendering, with a fallback to software if the video card can't do it. The video card's drivers are accessed through the interfaces defined by Direct3D, which is called by WPF's unmanaged personna "MILCore".
Ray Burns
thanks for all help
viky