我试图在Adobe Lightroom(http://www.youtube.com/watch?v=87hNd3vaENE)中创建类似于Lights out/lights dim功能的效果,但在WPF中除外.
我尝试的是在现有窗口的顶部创建另一个窗口,使其透明并在其上放置半透明的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>
Run Code Online (Sandbox Code Playgroud)
窗口是完全透明的,因此在路径未覆盖的位置,鼠标事件直接通过.到现在为止还挺好.路径对象上的IsHitTestvisible设置为false.因此鼠标事件将通过它传递到同一表单上的其他控件(即,您可以单击Button,因为它位于同一表单上).
但是鼠标事件不会通过Path对象传递到它下面的窗口.
有任何想法吗?还是更好的方法来解决这个问题?
谢谢.