您的位置:首页 > 其它

WPF下Window设置WindowStyle="None"时实现鼠标拖动移动窗口位置

2017-12-23 10:56 1606 查看
在WPF下当Window设置WindowStyle="None"时,默认的鼠标拖动窗口位置无效,需要自己定义代码实现,具体做法如下:
1、在xaml中引入MouseMove事件

<Window x:Class="Gvitech.Application.WPF.UI.FunFacility.WindowEquipmentRecord"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowEquipmentRecord" Height="360" Width="680" WindowStyle="None"
WindowState="Normal" AllowsTransparency="True" MouseMove="window_MouseMove" >

2、在代码中实现MouseMove代码 
private void window_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: