Sometimes you can get away with a small application to show off some features. But dragging rectangles around is just not enough. You need a TreeView, you need a GridView, ListBox and a good user feedback. Why not place everything in a Docking Control?
Some examples of DragDrop can be a bit unrealistic. You do not always have your elements defined in XAML. You cannot always have a reference to the containers you want to drag/drop. So we need to go a bit more real-world.
What I tried to do is create a simple application that uses the Model-View-ViewModel pattern and show how you can have a rich DragDrop with good user feedback.
Images speak more than words:
The result is the BugTracker sample application:
Another one showing DragDrop from list
Also then dragging multiple items with the same TreeView:
We all know about the Designer-Developer workflow and about Blend. But this is not to mean that every application we develop is designer-friendly or every application we design is developer-friendly, we actually need to take care about this. There are things like Dummy data, conditional DataCotnext, empty application resources that we need to be careful about to make an application blendable.
I did it:
Most amazingly it is visual-studio-friendly as well, you can see the changes as you type:
Even more amazingly the application is separated into views (as the MVVM pattern suggests) and each view gets its correct DataContext and is also editable in Blend and VS with full design-time:
I took the time to document the application so that you will be able to go around it quickly and find what you want. To do this I used the free HyperAddin which allows you to create hyperlinks in your code. A tour of the code:
Starting with the Contents:
And browsing through the important bits of the code by just following the hyperlinks:
I like to think of the example as a Hello Real World example that can evolve into a real-world example. With your help. What do you want to see next?
Valentin Stoychev (@ValioStoychev) for long has been part of Telerik and worked on almost every UI suite that came out of Telerik. Valio now works as a Product Manager and strives to make every customer a successful customer.
Subscribe to be the first to get our expert-written articles and tutorials for developers!