.net - 如果定义了背景,为什么面板元素只接收鼠标或手写笔事件?

标签 .net wpf

根据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/

相关文章:

WinForm应用程序中的WPF预编译资源?

WPF 命令绑定(bind)

c# - C# 中委托(delegate)的意外表现不佳

.net - 搜索 XML-FO 处理器

c# - machine.config appSettings 为空

wpf - WeakEventManager 和 DependencyPropertyChangedEventArgs

wpf - 使用 min(width, height)/2 作为半径在 WPF 中画一个圆

c# - WPF 中的 MenuItem 仅注册右键单击,但不注册左键单击

c# - 如何将凭据传递到计算机以便我可以在其上使用 Microsoft.Win32.RegistryKey.OpenRemoteBaseKey()?

c# - .net 核心中的 MissingManifestResourceException