I'm looking for a WPF drag drop library/article/tutorial that can:
Drag/drop to reorder list box items
Animate the panel as item is dragged (as shown in screen shot)
I've had a quick look at Telerik's DragDropManager, which comes with ListBoxDragDropBehavior. It provides drag/drop reordering, but not quite the behaviour as in my screenshot.
I would love to learn to write one from scratch eventually (adorners, animated panels, etc), but I'm currently time-constrained to using out-of-the-box libraries.
[edit]
The behaviour I'm looking for is the same as Windows 8's start screen
Check out Moving WPF DataGrid Rows using Drag and Drop which shows how to reorder DataGrid rows via drag drop and how to customize the drag indicator.
Related
I am trying to find a way to drag and drop between two grids(NOT datagrids). Both grids have 3 columns and the second grid gets populated based on whats dropped from first grid and the rows on second grid are generated dynamically. First grid has custom controls as icons. I am unable to get the items on the first grid as row/column co-ordinates but the mouse event handler gives me the (x,y) point co-ordinatels. Is there an easy way of doing this?
Thanks.
If I understand correctly then the main problem you have is to get the control under your mouse cursor. You can get it by using either UIElement.InputHitTest or VisualTreeHelper.HitTest to get that control / visual. Also do check out this article on MSDN: Hit Testing in the Visual Layer - it is a well-written explanation of this process with examples.
I implemented a drag and drop of an image from a Grid to another Grid using built-in MouseDragElementBehavior class. Then I needed to use a bit more complex layout for the source items so used ListBox and ItemTemplate instead.
The problem is now when dragging an item from the ListBox it is only visible when above the ListBox. How do I make it always visible and following mouse cursor anywhere while being dragged?
I suggest that instead of writing your own implementation using the Blend SDK, that you use the Silverlight Toolkit ListBoxDragDropTarget control.
The reason the item disappears in your element is that the MouseDragElementBehaviour is simplistically applying a render transform to affect the movement. However the ListView places its item panel inside a ScrollViewer which clips its content to its viewport.
This is the structure of my application:
Main Window has two ContentControls
Each ContentControl has a UserControl
Each UserControl has a ListBox
So graphically speaking, the user is presented with a Window with two ListBoxes: one with products and the other a shopping cart.
I want to enable drag-and-drop functionality among these two ListBoxes; i.e products can be dragged into the shopping cart.
I have seen examples of drag-and-drop between ListBoxes on the same window. But is it possible to drag and drop between UserControls?
I have looked at an example; is there a simpler way?
I came across a simple drag drop solution in Expression Blend; I tried searching for it, but in vain.
Drag-and-drop using behaviors is very simple. Download this complete implementation and sample and try it out:
ItemsControl Drag Drop Behavior for WPF
It is not clear what is a problem if you've already seen how to do drag-n-drop between listboxes on the same window. Use this code or tell us what's wrong with it.
The good thing about drag-n-drop functionality is that control which starts DND operation doesn't have to know anything regarding control which accepts DND result.
I have an interface pretty much identical to one located in the ExtJS examples page:
here
However, if you select items in the images panel, and then attempt to drag the scrollbar in any direction, the items are unselected and another drag instance is started. Makes sense on one level, but what if the user is trying to drag a large selection which involves panel scrolling?
Are there any quick fixes to allow me to drag and scroll without losing the drag selection?
Thanks!
Edit: Forgot to mention that this behaviour is reflected in the example listed above.
For those that are interested, I solved this by adding the following to the DataView:
autoHeight:true,
autoWidth:true,
style:'overflow:auto'
and added this to the Panel holding the DataView
autoScroll:true
I'm trying to write a WPF control that has similar functionality to the Windows Sidebar.
The functionaly I would like to replicate is the drag and drop ordering. When dragging an item the other items move out of the way to show you where the item will end up when dropped.
Has anyone else had to implement this sort of functionality, if so how did you go about it?
I've been meaning to write something like that myself, but haven't quite gotten there yet. Take a look at Bea Stollnitz's drag and drop post. The insert adorner isn't the main focus of her post, but she discusses it.