36 lines
921 B
C#
36 lines
921 B
C#
|
|
using Microsoft.Xaml.Behaviors;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Controls;
|
|||
|
|
using System.Windows.Input;
|
|||
|
|
|
|||
|
|
namespace SamplePreSystem.UI.Behaviors
|
|||
|
|
{
|
|||
|
|
public class BorderMouseMoveBehavior :Behavior<Border>
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
protected override void OnAttached()
|
|||
|
|
{
|
|||
|
|
//base.OnAttached();
|
|||
|
|
|
|||
|
|
AssociatedObject.MouseMove += AssociatedObject_MouseMove;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AssociatedObject_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.LeftButton == MouseButtonState.Pressed)
|
|||
|
|
{
|
|||
|
|
// 获取窗口并执行拖拽
|
|||
|
|
if (Window.GetWindow(AssociatedObject) is Window window)
|
|||
|
|
{
|
|||
|
|
window.DragMove();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|