根据http://msdn.microsoft.com/de-de/library/system.windows.controls.panel.background.aspx
Panel elements do not receive mouse or stylus events if a Background is not defined. If you need to handle mouse or stylus events but do not want a background for your Panel, use Transparent.
所以我的问题是:为什么?有人知道这种行为的原因吗?
最佳答案
原因是输入是基于Hit Testing in the Visual Layer 。特别请参阅 HitTest 支持部分。
HitTest 仅在视觉对象的渲染内容(即渲染的几何图形)上成功。当您设置其 Background
属性时,Panel 最终会将填充的 RectangleGeometry 渲染为背景。
关于.net - 如果定义了背景,为什么面板元素只接收鼠标或手写笔事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10187396/