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

时间:2021-04-23 12:24:36   收藏:0   阅读:0

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 }

技术图片

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!