
Untitled
By: a guest on
Jun 16th, 2012 | syntax:
None | size: 0.86 KB | hits: 18 | expires: Never
Implementing Drag and Drop similar
public partial class CustomItem : UserControl
{
private bool IsDragging { get; set; }
private Point clickPosition;
public CustomItem()
{
InitializeComponent();
this.DataContext = this;
this.MouseLeftButtonDown += (s, ea) =>
{
clickPosition = ea.GetPosition(this.LayoutRoot);
this.CaptureMouse();
IsDragging = true;
};
this.MouseMove += (s, ea) =>
{
if (IsDragging)
{
this.transFormThisShit.X = ea.GetPosition(this).X - clickPosition.X;
this.transFormThisShit.Y = ea.GetPosition(this).Y - clickPosition.Y;
}
};
this.MouseLeftButtonUp += (s, ea) =>
{
this.ReleaseMouseCapture();
IsDragging = false;
};
}
}