[WPF]当Panel控件背景色为空的时候,不能在没有子控件的区域出发事件

本文详细解释了WPF中Background属性设置为null和Transparent的区别。当设置为null时,不会发出任何绘制指令,并且不参与命中测试;而设置为Transparent时,则会正常发出绘制指令并参与命中测试。此外,还介绍了MILCore如何处理这些情况。

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 withBrushes.Transparent are part of the application, so clicking on it does nothing. This is done by special-casing Brushes.Transparent for this purpose.

 

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" 

转载于:https://www.cnblogs.com/tianya-wy/archive/2010/02/10/1667343.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值