When the thumb is rotated 90 degrees following the grid, it will fly off when the control is dragged.
<Gridx:name= "Gridmain"Width= "+"Height= " the"Background= "Green"Rendertransformorigin= "0.5,0.5"Canvas.Left= "+"Canvas.Top= "+"> <Grid.rendertransform> <RotateTransformx:name= "Rotate"Angle= "All"></RotateTransform> </Grid.rendertransform> <Thumbx:name= "Thumbmain"Opacity= "0.8"DragDelta= "Thumb_dragdelta"></Thumb> </Grid>
Private void Thumb_dragdelta (object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { + e.horizontalchange); + E.verticalchange); }
This is due to a non-uniform coordinate system. Canvas.seltleft and Canvas.settop are the Canvas coordinate systems used. The E.horizontalchange and e.verticalchange of the thumb are calculated based on the mouse relative to the thumb's own coordinate system, and the two coordinate systems have a 90 degree angle difference. Will E. Horizontalchange and E.verticalchange into the canvas's coordinate system, drag and drop is no problem. As follows:
Private void Thumb_dragdelta (object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e) { = rotate. Transform (new point (E.horizontalchange, E.verticalchange)); + ptchange.x); + ptchange.y); }