Making a WPF window click-through, but not its controls

前端 未结 1 1476
粉色の甜心
粉色の甜心 2021-01-01 00:18

First of all I want to define what I mean by transparent to clicks in the text bellow: It means the clicks go through my window without any processing, directly to

相关标签:
1条回答
  • 2021-01-01 00:38

    Can you try this

    <Window x:Class="WpfApplication1.Window1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Window1"
            Height="300"
            Width="300"
            AllowsTransparency="True"
            WindowStyle="None" >
        <Window.Background>
            <SolidColorBrush Color="#FFB0B0B0"
                             Opacity="0.05" />
        </Window.Background>
        <Grid>
            <Button Content="Button"
                    HorizontalAlignment="Left"
                    Margin="39,125,0,0"
                    VerticalAlignment="Top"
                    Width="75" />
            <Label Content="Label"
                   HorizontalAlignment="Left"
                   Margin="114,50,0,0"
                   VerticalAlignment="Top" />
            <TextBox HorizontalAlignment="Left"
                     Height="23"
                     Margin="101,201,0,0"
                     TextWrapping="Wrap"
                     Text="TextBox"
                     VerticalAlignment="Top"
                     Width="120" />
    
        </Grid>
    </Window>
    

    What It basically does Is create a transparent window.(Click through and Invisble). But controls are visible and not-click through. Or you can try How to create a semi transparent window in WPF that allows mouse events to pass through

    0 讨论(0)
提交回复
热议问题