Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 16th, 2012  |  syntax: None  |  size: 0.86 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Implementing Drag and Drop similar
  2. public partial class CustomItem : UserControl
  3. {
  4.     private bool IsDragging { get; set; }
  5.     private Point clickPosition;
  6.     public CustomItem()
  7.     {
  8.         InitializeComponent();
  9.         this.DataContext = this;
  10.         this.MouseLeftButtonDown += (s, ea) =>
  11.         {
  12.             clickPosition = ea.GetPosition(this.LayoutRoot);
  13.             this.CaptureMouse();
  14.             IsDragging = true;
  15.         };
  16.         this.MouseMove += (s, ea) =>
  17.         {
  18.             if (IsDragging)
  19.             {
  20.                 this.transFormThisShit.X = ea.GetPosition(this).X - clickPosition.X;
  21.                 this.transFormThisShit.Y = ea.GetPosition(this).Y - clickPosition.Y;
  22.             }
  23.         };
  24.         this.MouseLeftButtonUp += (s, ea) =>
  25.         {
  26.             this.ReleaseMouseCapture();
  27.             IsDragging = false;
  28.         };
  29.     }
  30. }