标签:
<Grid > <Canvas Name ="g" Background="AliceBlue" HorizontalAlignment="Left" Height="100" Margin="41,72,0,0" VerticalAlignment="Top" Width="151"> <Thumb Canvas.Top ="2" Canvas.Left="2" Width="35" Height="35" DragDelta="Thumb_DragDelta"
DragStarted="Thumb_DragStarted" DragCompleted="Thumb_DragCompleted"></ Thumb> <TextBlock Canvas.Top ="2" Canvas.Left="2" x:Name ="tt" FontSize="24" ></TextBlock> </Canvas> </Grid>
private void Thumb_DragDelta( object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { Thumb myThumb = (Thumb )sender; double nTop = Canvas .GetTop(myThumb) + e.VerticalChange; double nLeft = Canvas .GetLeft(myThumb) + e.HorizontalChange; Canvas.SetTop(myThumb, nTop); Canvas.SetLeft(myThumb, nLeft); tt.Text = "Top:" + nTop.ToString() + "\nLeft:" + nLeft.ToString(); } private void Thumb_DragStarted(object sender, DragStartedEventArgs e) { tt.Text = "哈哈 这个玩意可以拖" ; } private void Thumb_DragCompleted(object sender, DragCompletedEventArgs e) { tt.Text = "终于拖结束了" ; }
标签:
原文地址:http://www.cnblogs.com/JasonShenW/p/4932650.html