WPF 窗体设置WindowStyle="None"鼠标移动窗体

1.WPF 窗体设置WindowStyle="None"属性的时候,是没有办法通过鼠标移动窗体的。

2.如何解决呢?

3.在Window窗体添加 MouseLeftButtonDown 事件。

 1 <Window x:Class="UI.Windows.Login"
 2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 5         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6         mc:Ignorable="d"
 7         Title="Login" Height="500" Width="500"  WindowStyle="None" ResizeMode ="NoResize" 
 8         WindowStartupLocation ="CenterScreen"  MouseLeftButtonDown="BaseWindow_V_MouseLeftButtonDown">
 9     <Grid>
10         <TextBlock Text="https://www.cnblogs.com/yellow3gold/" FontFamily="Calibri" FontSize="20" Foreground="Red"/>
11     </Grid>
12 </Window>
1 private void BaseWindow_V_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
2 {
3     if (e.ButtonState == MouseButtonState.Pressed)
4     {
5         this.DragMove();
6     }
7 }

 

posted @ 2021-04-23 08:38  新*  阅读(455)  评论(0编辑  收藏  举报