我正在创建WPF应用程序,它具有如下所示的抓握区域和半透明鼠标直通区域。
+----+---------------------------+
|Grip| |
+----+ |
| Semi-transparent region with |
| mouse pass-through |
+--------------------------------+
XAML:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
WindowStyle="None" Background="Transparent" AllowsTransparency="True" Topmost="True" >
<Grid>
<!-- I want to make this contents pass-through -->
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#7F000000" Offset="0"/>
<GradientStop Color="#00000000" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Label Content="Semi-transparency mouse pass-through region"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<!-- except this -->
<Rectangle Name="grip"
Width="50" Height="50"
Fill="#7F000000"
VerticalAlignment="Top"
HorizontalAlignment="Left" />
</Grid>
</Window>
根据this question,我尝试为我的窗口设置WS_EX_TRANSPARENT
,但此方法无法处理窗口消息以移动窗口或调整窗口大小。
所以,我的问题是,有没有办法使用WPF制作上述窗口?
修改:除了抓握,我想制作我的窗口like this。