Search code examples
wpfformsdraggable

Is there a reference to WPF which enables controls being Draggable?


I've got an application in WPF in which I want to make some controls draggable on the canvas. I know there is a Nuget package Control.Draggable for Windows.Forms but it conflicts with my WPF code:

using System.Windows.Forms;
public partial class MainWindow : Window
 {
 System.Windows.Controls.Button newButton = new System.Windows.Controls.Button();
 ControlExtension.Draggable(newButton, true);
  }

Error message underlining newButton:

Cannot convert from 'System.Windows.Controls.Button' to 'System.Windows.Forms.Control'

Is there any way to overcome this error and easily apply draggable feature in WPF?


Solution

  • You may want to check out dong-wpf-dragdrop. It's an open-source library that makes it easy to implement and use drag-and-drop functionality in WPF.