Now that I can make useful user controls in WPF (thanks to this stackoverflow answer) I want to be able to put numerous user controls on one page in two columns and enable the user to be able to move them around according to preference, dragging the ones they use the most to the top, etc.
Can anyone point me to code, tutorials, etc. which do this? I can imagine this has been made quite easy to do in WPF.
In the drag source event handler, call the DoDragDrop method to initiate the drag-and-drop operation. In the DoDragDrop call, specify the drag source, the data to be transferred, and the allowed effects. Identify the element that will be a drop target. A drop target can be UIElement or a ContentElement.
User controls, in WPF represented by the UserControl class, is the concept of grouping markup and code into a reusable container, so that the same interface, with the same functionality, can be used in several different places and even across several applications.
Using a user control in XAML is pretty simple. I use a WPF Application to test the control. Create a WPF application project and copy the control code files to your project. After that, you need to add namespace of the library in which the user control is defined.
Here is a blog post to get you started on drag drop functionality in WPF.
Have Fun.
There's also How can I drag and drop items between data bound ItemsControls? by Bea Stollnitz.
The article talks about a reusable set of adorners that enable drag-n-drop between controls.
It's somewhat advanced, but very useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With