The basic idea is simple:
First get the position of the mouse click and record, move the mouse to get the location after the move to calculate the travel value, and then pan.
Code:
Using System; Using System.Collections.Generic; Using System.Linq; Using System.Text; Using System.Windows; Using System.Windows.Controls; Using System.Windows.Data; Using System.Windows.Documents; Using System.Windows.Input; Using System.Windows.Media; Using System.Windows.Media.Imaging; Using System.Windows.Navigation; Using System.Windows.Shapes; namespace Dragwindowtest {///// MainWindow.xaml's interactive logic /// Public partial class Mainwindow:window {public MainWindow () {Initializecompo Nent (); } private static bool Isdrag = FALSE; Private double Enterx; Private double entery; private void Window_mouseleftbuttondown (object sender, MouseButtonEventArgs e) {Isdrag = true; Enterx = E.getposition (this). X Entery = E.getposition (this). Y private void Window_mouseleftbuttonup (object sender, MouseButtonEventArgs e) {Isdrag = false; Enterx = 0; entery = 0; private void Window_mousemove (object sender, MouseEventArgs e) {if (Isdrag) {this. Left + = E.getposition (this). X-enterx; This. Top + = E.getposition (this). Y-entery; } } } }