我试图在WPF中创建类似Adobe Lightroom(http://www.youtube.com/watch?v=87hNd3vaENE)中的灯光关闭/变暗特效。
我的尝试是在现有窗口上创建另一个窗口,将其设置为透明,并在其上放置半透明的Path几何图形。但我希望鼠标事件能够穿透这个半透明的窗口(传递到下面的窗口)。
以下是简化版本:
<Window x:Class="LightsOut.MaskWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
AllowsTransparency="True"
WindowStyle="None"
ShowInTaskbar="False"
Topmost="True"
Background="Transparent">
<Grid>
<Button HorizontalAlignment="Left" Height="20" Width="60">click</Button>
<Path IsHitTestVisible="False" Stroke="Black" Fill="Black" Opacity="0.3">
<Path.Data>
<RectangleGeometry Rect="0,0,1000,1000 "/>
</Path.Data>
</Path>
</Grid>
窗口完全透明,所以在路径未覆盖的地方,鼠标事件会直接穿过。到目前为止一切正常。路径对象上的IsHitTestvisible属性设置为false。因此,鼠标事件会穿过它,传递到同一表单上的其他控件(例如,您可以单击按钮,因为它在同一表单上)。
但鼠标事件不会穿过路径对象并传递到其下面的窗口。
有什么想法吗?或者更好的解决方法?
谢谢。