添加项目文件。
This commit is contained in:
35
SamplePreSystem.UI/Behaviors/BorderMouseMoveBehavior.cs
Normal file
35
SamplePreSystem.UI/Behaviors/BorderMouseMoveBehavior.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user