wpf控件拖动

Thumb 拖动 上代码!

 1 <Window x:Class="Thumb控件移动.MainWindow"
 2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 4         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 5         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6         xmlns:local="clr-namespace:Thumb控件移动"
 7         mc:Ignorable="d"
 8         Title="MainWindow" Height="350" Width="525">
 9     <Grid Name="grid">
10         <Grid Height="50" Width="50" Background="Red">
11             <Thumb DragDelta="Thumb_DragDelta" Opacity="0">
12        
13         </Thumb>
14         </Grid>
15     </Grid>
16 </Window>
1         private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
2         {
3             Thickness margin = grid.Margin;
4             margin.Top += e.VerticalChange;
5             margin.Bottom -= e.VerticalChange;
6             margin.Left += e.HorizontalChange;
7             margin.Right -= e.HorizontalChange;
8             grid.Margin = margin;
9         }

好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!好了可以愉快的拖动了!!!!!!!!!!!!!!!

相关推荐:

如何基于内容精准定位无标题的 ComboBox 控件

本文介绍在pywinauto(uia后端)中,当多个combobox缺乏唯一标识(如title、automationid)时,如何通过索引定位并验证目标下拉框,避免elementambiguouserror。 本文介绍在pywinauto(uia后端)中,当多个combobox缺乏唯一标识(如tit...

动态更新 Tkinter 界面控件的正确实践:避免阻塞主线程

本文详解如何在tkinter中实现实时、流畅的界面更新,解决因耗时操作(如传感器读取)导致界面冻结、控件延迟刷新的问题,核心方案是分离i/o与gui线程,并通过线程安全机制协同更新。 本文详解如何在tkinter中实现实时、流畅的界面更新,解决因耗时操作(如传感器读取)导致界面冻结、控件延迟刷新的问...