发布网友 发布时间:2022-04-22 06:04
共4个回答
热心网友 时间:2023-09-27 02:43
如果要作成透明的话,窗体本身很难获得Mouse事件,直接点到后面的东西去了,我做了个例子
Window.xmal代码:
<Window x:Class="Test.Class1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Right Click To Close" Height="300" Width="300"
WindowStyle="None" AllowsTransparency="True" MouseRightButtonUp="WindowClicked"
Background="{x:Null}"
>
<Grid MouseRightButtonDown="WindowClicked">
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=Title}"
FontSize="18" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="20"
MouseLeftButtonDown="DragWindow" FontFamily="Impact" Foreground="Red"/>
<Viewbox Stretch="Uniform" MouseLeftButtonDown="DragWindow">
<Path Fill="#80D0E0FF" Stroke="Red" StrokeThickness="0" HorizontalAlignment="Center" VerticalAlignment="Center"
Data="M79,3L65,82 17,91 50,138 96,157 104,192 175,154 190,167 218,78 156,76 157,9 111,39z"/>
</Viewbox>
</Grid>
</Window>
Window.xmal.cs 代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Test
{
public partial class Class1 : System.Windows.Window
{
public Class1()
{
InitializeComponent();
}
public void DragWindow(object sender, MouseButtonEventArgs args)
{
DragMove();
}
public void WindowClicked(object sender, MouseButtonEventArgs args)
{
Close();
}
}
}
热心网友 时间:2023-09-27 02:43
form的试过,wpf的还没玩过
热心网友 时间:2023-09-27 02:44
FORM的简单 WPF是这东东还没用过
热心网友 时间:2023-09-27 02:44
穿透?还是不显示鼠标的光标?