WPF怎么实现鼠标拖动无标题的窗口移动
调试时出现错误
找不到类型或命名空间名称“MouseEventArgs”(是否缺少using指令或程序集引用?)
是不是鼠标拖动控件需要加什么引用啊?刚玩了一天WPF还什么都不懂,麻烦大家教教!
前台部分代码:
…………
<Label FontSize="36" Width="297.5" Height="60.5" Content="测重" FontWeight="Bold" x:Name="MainTitle" Foreground="#FFFFC800" HorizontalAlignment="Left" Margin="52,14,0,0" VerticalAlignment="Top" MouseLeftButtonDown="MainTitle_MouseLeftButtonDown" MouseLeftButtonUp="MainTitle_MouseLeftButtonUp" MouseMove="MainTitle_MouseMove" />
…………
后台代码:
using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
namespace Weighing
{
public partial class Window1
{
public Window1()
{
this.InitializeComponent();
// 在此点之下插入创建对象所需的代码。
}
/// <summary>
/// Move the window.
/// </summary>
private void MainTitle_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
}
…………
}
------解决方案--------------------添加命名空间
using System.Windows.Input;