Home > Net >  WPF drag problem for help
WPF drag problem for help

Time:11-11

Private void Element_MouseMove (object sender, MouseEventArgs e)
{
If (isDragDropInEffect)
{
FrameworkElement currEle=sender as FrameworkElement;
Double xPos=um participant etPosition (this). X-ray pos. X + currEle. Margin. The Left;
Double yPos=um participant etPosition (this) - pos. Y Y + currEle. Margin. The Top;
CurrEle. Margin=new Thickness (xPos, xPos, 0, 0);
Pos=um participant etPosition (null);
}
}

Private void Element_MouseLeftButtonDown (object sender, MouseButtonEventArgs e)
{
FrameworkElement fEle=sender as FrameworkElement;
IsDragDropInEffect=true;
Pos=um participant etPosition (null);
FEle. CaptureMouse ();
FEle. Cursor=your Cursors. Hand;
}



The mouse control, the control can't keep up with the mouse speed, and finally finish the mouse shows not stop position in the mouse,

CodePudding user response:

Help!!!!!! Just learning not long time, thank you very much

CodePudding user response:

Mobile is with Thumb, temporary write a simple example of
The front desk, add a canvas, name "MainBox
 
.
Title="MainWindow" Height="450" Width="800" & gt;





The background
 
Public MainWindow ()
{
InitializeComponent ();

Canvas Move_Box=new Canvas ()
{
Width=100,
Height=100,
Background=Brushes. Green
};
Canvas. SetLeft (Move_Box, 10);
Canvas. SetTop (Move_Box, 10);
MainBox. Children. The Add (Move_Box);

Thumb Thumb=new Thumb ()
{
Width=100,
Height=100,
Opacity=0
};
Thumb. DragDelta +=(s, e)=& gt;
{
Canvas. SetLeft (Move_Box, Canvas. GetLeft (Move_Box) + e.H orizontalChange);
Canvas. SetTop (Move_Box, Canvas. GetTop (Move_Box) + e.V erticalChange);
};
Move_Box. Children. The Add (thumb);
}

CodePudding user response:

I didn't write canvas with border and the embedded web page
In front of the web pages to write.

CodePudding user response:

AAA
reference 3 floor summer smoking a cup of cold drink I reply:
I didn't write canvas with border and embedded web
In front of the web pages to write.


Then you put the outermost layers within the Grid is a Canvas, put Border, web page or something isn't finished,
Don't put the Canvas, with XXX. SetValue (xx, xx). As with setting properties
  •  Tags:  
  • C#
  • Related