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         }

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

posted @ 2018-08-24 18:13  葡萄老祖  阅读(832)  评论(0编辑  收藏  举报