开发者

Wpf Panel Background problem

开发者 https://www.devze.com 2022-12-11 18:54 出处:网络
When i don\'开发者_运维技巧t set background of my panel i can not get mouse events on that. why this behaviour?

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消