punker76 / gong-wpf-dragdrop Goto Github PK
View Code? Open in Web Editor NEWThe GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF
License: BSD 3-Clause "New" or "Revised" License
The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF
License: BSD 3-Clause "New" or "Revised" License
Original author: [email protected] (June 04, 2010 12:57:40)
Suddenly an unhandled Exception is thrown namely:
'System.Windows.Documents.Run' is not a Visual or Visual3D'
The exception occurs in
VisualTreeExtensions.cs in the Method GetVisualAncestor<T>(this
DependencyObject d) where T : class
To solve the problem I would add a check like so:
public static T GetVisualAncestor<T>(this DependencyObject d) where T :
class
{
if (d is Visual || d is System.Windows.Media.Media3D.Visual3D)
{
DependencyObject item = VisualTreeHelper.GetParent(d);
while (item != null)
{
T itemAsT = item as T;
if (itemAsT != null) return itemAsT;
item = VisualTreeHelper.GetParent(item);
}
}
return null;
}
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=17
Original author: [email protected] (April 27, 2011 06:50:20)
I would begin with that, this is a wonderful framework for Drag and Drop in wpf.
Ok, with that said, there was a small issue that I had been facing. I just wanted to report that and also how I resolved it? I was trying this framework with a ListView. My listview control is my DragSource(=True). Incidently, the listview also has its context menu. Now the problem arises when I right-click on an item and then (just to close the context menu) click anywhere (sometimes on one of the items) on the listview. Now when I would click on one of the items, it sets System.Windows.DragDrop.DoDragDrop(,,,), in the DragSource_PreviewMouseMove event handler, even though I had just clicked the left button (not dragged it). It would have been fine otherwise, but in this case it does not fire the PreviewMouseLeftButtonUp event, with the result that my Mouse pointer stops taking any input. I am not able to click on any other button on the window untill I minimize and then maximize the window. Now here is the list of events that could be reason of the problem;
1.I right click on an item in listview to bring-up the Context menu.
2.I donot click on the Context menu item and instead click on some listviewitem again to close the context menu
-here, first PreviewMouseLeftButtonDown is called which is handled by DragSource_PreviewMouseLeftButtonDown
-inside this handler this code, "mDragInfo = new DragInfo(sender, e);" creates mDragInfo
-inside the ctor of mDragInfo, this code, "DragStartPosition = e.GetPosition(null);" sets the DragStartPosition, BUT RELATIVE TO MY CONTEXT MENU
-then, PreviewMouseMove is called which is handled by DragSource_PreviewMouseMove
-here, this code, "Point position = e.GetPosition(null);" takes the position again, BUT THIS TIME RELATIVE TO MY LISTVIEW
-and when it compares the two positions in the code below, it evaluates to True;
if (Math.Abs(position.X - dragStart.X) > SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs(position.Y - dragStart.Y) > SystemParameters.MinimumVerticalDragDistance)
-and this leads to setting the System.Windows.DragDrop.DoDragDrop(,,,)
which wouldn't have otherwise happened if it would be a simple mouse-click on a list view
To resolve it, I simply took "sender" as argument for the two e.GetPosition() statements (one in the ctor of DragInfo and the other in DragSource_PreviewMouseMove event handler). Since, in my case the sender in context of both the statements was the same listview, so I could get it right.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=35
Original author: [email protected] (May 05, 2010 09:27:51)
Hi Grokys. Looks like its getting busy on the drag and drop front!
Anyway I've been playing around on my branch of the code. One thing that
I've needed to change is the events from the 'Preview' versions to the
standard event version. i.e. Switching the events from tunnelling to
bubbling.
This change means that I can put nest controls that all support drag and
drop. (I think this is also the issue that FreakOnALuis is getting when
using a slider on a draggable element.)
So my question is what was the reason for picking the tunnelling event? So
far I haven't found any issues with making this change but just because I
haven't found anyway doesn't mean there aren't any. Am I missing something?
Thanks,
Jon
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=12
Original author: [email protected] (November 08, 2011 14:43:34)
What steps will reproduce the problem?
(I took SchoolsExmaple sample code in Code Project for example.)
Then you can see checking doesn't work.
Hi!
First of all I want to thank you all for your wonderful work.
I try to take you dll for drag and drop but it doesn't work well.
In attached file you can see what is my problem.
When I remove ListBox's SelectionMode="Multiple" then it's a little bit fine.
I think it's because mouse click prblem on list box(which is able to drag and drop)
Help me.
Thank you.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=41
Original author: [email protected] (January 14, 2010 20:42:43)
I really appreciate what you have done. I would like to use your project, but
I haven't found the way how to only move items. Copy is no use for me.
Is it a unknown feature, or future feature, or not featured at all?
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=4
Original author: [email protected] (February 09, 2010 14:53:09)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I can see that the drop event is executed twice.Also after the events the
mouse clicks are not recognized any more.If i move the mouse out of the
application(suppose taskbar) then everything works fine.Where has my mouse
clicks gone..?Please give me a solution
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=5
Original author: [email protected] (November 28, 2012 21:21:30)
Hey can we get an official GongSolutions.Wpf.DragDrop package in NuGet?
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=50
Original author: [email protected] (July 08, 2010 13:36:34)
Not sure what your final plans are.
But we are needing to drag items from controls which are not item controls.
such as DevExpress Grids, Images etc
At the moment the DragInfo was tightly couple to the Drag Source being ItemsControl.
This patch abstracts the creation of DragInfo behind a factory allowing for other IDragInfo to be created.
Factory can be set like the handler via dependency property
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=26
Original author: neilboyd (October 12, 2011 08:26:14)
It would be very handy if DefaultDropHandler was public so that I can use it's static methods in my own implementation.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=40
Original author: [email protected] (December 15, 2011 10:10:19)
What steps will reproduce the problem?
<ItemsControl ItemsSource="{Binding Collection}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Label>WhatEver</Label>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
It all happens in DragInfo's constructor.
This line fails to retrieve the correct container:
UIElement item = itemsControl.GetItemContainer((UIElement)e.OriginalSource);
Therefore itemParent is null:
ItemsControl itemParent = ItemsControl.ItemsControlFromItemContainer(item);
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=42
Original author: [email protected] (November 15, 2012 23:44:01)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I would like the Dropped function on my view model A to be called when a drop occurs
Instead of the one ine the DefaultDragHandler
What version of the product are you using? On what operating system?
Last one, Windows 7
Please provide any additional information below.
Looking at the code, it seems that the issue came from
file: DragDrop.cs
function: static void DropTarget_PreviewDrop(object sender, DragEventArgs e)
Line: IDragSource dragHandler = GetDragHandler((UIElement)sender) ?? DefaultDragHandler;
We are getting the DragSource of the sender uiElement which is the target one (i.e. LBB)
I fixed it by replacing the line with this one:
IDragSource dragHandler = GetDragHandler(_DragInfo.VisualSource) ?? DefaultDragHandler;
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=49
Original author: [email protected] (April 13, 2012 09:24:13)
With this changes is it possible, to check the DragDropKeyState-Value in the IDropTarget.DragOver method. So you can e.g. check if ctrl Key is pressed and change from move to copy effect.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=46
Original author: [email protected] (April 12, 2012 14:28:28)
What steps will reproduce the problem?
Customize the SchoolsExample:
What is the expected output? What do you see instead?
The item should be focused and selected.
What version of the product are you using? On what operating system?
0.1.2 Windows 7
Please provide any additional information below.
To solve this problem, add these lines at the begin of "DragDrop.DragSource_PreviewMouseLeftButtonDown":
...
if (e.ClickCount != 1)
return;
...
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=45
Original author: [email protected] (January 12, 2012 16:43:10)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
The IDropTarget methods are never fired.
What version of the product are you using? On what operating system?
GongSolutions.Wpf.DragDrop-0.1.2.zip on Windows 7.
Please provide any additional information below.
To be honest, I'm not sure if this is a Gong problem or AvalonDock problem. Just putting it out there that Gong DragDrop and AvalonDock don't play nice. Note that everything works perfectly in a non-floating (docked) window.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=44
Original author: [email protected] (May 04, 2010 09:36:10)
What steps will reproduce the problem?
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=10
Original author: [email protected] (May 04, 2010 14:56:40)
When you start dragging and your window isn't the main one, the dragAdorner
isn't shown.
Please change CreateDragAdorner into:
static void CreateDragAdorner()
{
DataTemplate template =
GetDragAdornerTemplate(m_DragInfo.VisualSource);
if (template != null)
{
UIElement rootElement = null;
// Find the current top window
Window parentWindow =
TryFindParent<Window>(m_DragInfo.VisualSource);
if (parentWindow != null)
rootElement = parentWindow.Content as UIElement;
if (rootElement == null)
rootElement =
(UIElement)Application.Current.MainWindow.Content;
UIElement adornment = null;
....
The TryFindParent method is well documented at
http://www.hardcodet.net/2008/02/find-wpf-parent
Good luck,
Frank
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=11
Original author: [email protected] (July 08, 2010 09:43:26)
Attached a patch to use interfaces for Drag and Drop Info.
Makes it easier to unit test handlers
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=24
Original author: [email protected] (May 17, 2012 19:51:46)
In DragDrop.cs
static bool HitTestScrollBar(object sender, MouseButtonEventArgs e)
{
HitTestResult hit = VisualTreeHelper.HitTest((Visual)sender, e.GetPosition((IInputElement)sender));
return hit != null && hit.VisualHit.GetVisualAncestor<System.Windows.Controls.Primitives.ScrollBar>() != null;
}
The HitTestResult was null. I added the 'hit != null &&' to the condition in the return value.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=47
Original author: [email protected] (May 06, 2010 13:07:45)
Is it possible to implement raise events DropCompleted and DragCompleted?
In the args info about the source, target and data, or just DropInfo.
Thanks,
Frank
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=14
Original author: [email protected] (February 18, 2011 19:21:53)
Dropping a child element into a treeviewitem will not add the element as a child of the treeviewitem.
Take the default sample application, look at the 'bound treeview' window and drag all of the children from one parent to another, then once empty, try to drag one of the children back to the original parent.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=31
Original author: [email protected] (June 07, 2010 17:16:02)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I expect all the selected items to be deselected/unselected and the just
selected item to be selected. Instead nothing happens - all the items
remain selected.
What version of the product are you using? On what operating system?
0.1.2 on Windows 7
Please provide any additional information below.
If another selected item (not the first one we selected) is being simple
clicked (to select it and remove all other selections) it works - anyway
it doesnt work if we try to do that for the FIRST selected item.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=21
Original author: neilboyd (October 11, 2011 15:12:39)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
You will see that the highlight outline covers the space that Root1 did have when it was expanded.
It should only cover the now collapsed space.
What version of the product are you using? On what operating system?
Revision 38. Windows XP.
Please provide any additional information below.
Patch to fix it is attached.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=39
Original author: [email protected] (April 11, 2010 22:40:46)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
When you try do drag one item, grabbing it within the TextBox, the application stops in CanAcceptData (DefaultDropHandler.cs)
at:
"if (dropInfo.DragInfo.SourceCollection == dropInfo.TargetCollection)"
because dropInfo.DragInfo is null.
What version of the product are you using? On what operating system?
0.1.2
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=9
Original author: [email protected] (May 27, 2010 08:50:55)
The Adorner is only visible when effects != none AND dragsource does also
accept drops.
I don't know about the window guidelines, but I like that the Adorner is
always visible (even if the source doesn't accept drops).
I did accomplish this in two ways:
I came up with this idea as it is a bit strange that when you start
dragging you only see the "forbidden sign" and when a drag is allowed
you'll see the adorner with the "copy sign".
What do you think about this?
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=16
Original author: [email protected] (June 22, 2011 19:57:42)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=37
Original author: [email protected] (January 16, 2011 15:53:40)
I have a ListBox which uses a custom item container class (derived from ListBoxItem). After enabling drag and drop for this ListBox (using dd:DragSource = "true" dd:DropTarget = "true") selecting any item was not possible anymore.
The problem is caused by, GetItemContainer not finding my custom derived item container class.
I'd recommend changing GetVisualAncestor not to use "==" for type checking, but using something which is comparable to the "is" operator:
public static DependencyObject GetVisualAncestor(this DependencyObject d, Type type)
{
DependencyObject item = VisualTreeHelper.GetParent(d);
while (item != null)
{
if (item.GetType() == type ||
item.GetType().IsSubclassOf(type))
return item;
item = VisualTreeHelper.GetParent(item);
}
return null;
}
After this change the problem is gone.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=30
Original author: [email protected] (November 07, 2009 19:14:39)
When clicking an item and moving the mouse quickly, rather than a drag on the
item that was clicked on being dragged, sometimes the selection changes
before the drag is started. This is particularly noticeable if clicking the
item causes the UI to lock up for a short time.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=1
Original author: [email protected] (June 07, 2010 10:06:19)
I need to know the mouse position when the drop takes place. Could you
please add the following code to the control?
All in DropInfo.cs
public DropInfo()
{
...
VisualTarget = sender as UIElement;
if (VisualTarget == null)
return;
DropPosition = e.GetPosition(VisualTarget);
if (sender is ItemsControl)
...
(and change the position part in DropPosition here)
}
And add the following code to end of this class:
/// <summary>
/// Gets the mouse position relative to the VisualTarget
/// </summary>
public Point DropPosition { get; private set; }
Once again thanks,
Frank
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=19
Original author: [email protected] (August 10, 2010 21:29:00)
What steps will reproduce the problem?
I feel the current implementation does not support nested Listboxes :(
Is there a way to accomplish that?
I have something like this:
Parent ListBox
-- PListBoxItem1
-- PListBoxItem2
-- PListBoxItem3
---- Child ListBox
------ Child ListBoxItem1
------ Child ListBoxItem2 -Click drag started here
------ Child ListBoxItem3
The current implementation is always detecting ParentListBox as DragSource...
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=28
Original author: [email protected] (June 18, 2010 19:06:29)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I expect the just clicked item to get selected without doing anything.
Instead the Framework thinks that I want to drag the item on which the ContextMenu was opened and therefor calls the Drop-Handler.
What version of the product are you using? On what operating system?
Windows 7, newest Version (just updated)
Please provide any additional information below.
Please check this and my other two issues. Thank you.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=22
Original author: [email protected] (April 05, 2010 20:20:37)
What steps will reproduce the problem?
Implement extended selection and IsDragSource on a ListBox
<ListBox ...
SelectionMode="Extended"
dd:DragDrop.IsDragSource="True" />
Select a least two items on the ListBox
On a selected item do a mouse click and release the mouse button.
What is the expected output? What do you see instead?
I expect that only one item was selected.
Instead of these behavior the selection not change.
If you select all items, then you dont have chance to unselect all items.
The selection must change only on MouseUp, otherwise could not do multiple
DragDrop.
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=8
Original author: [email protected] (January 02, 2012 10:20:39)
Let's explain the context. I have a treeview or a list with 3 items. I want to move the last one to above the first item. If I apply the move effect it appears a line that shows me the place I would like to place my item. Depending where I put my mouse pointer on the first item I see that line under or abover that first element.
My question. How can I get that position when I perform the drop action?
Thank you
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=43
Original author: [email protected] (July 02, 2010 11:52:23)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I expected the adorner to appear in the second window, but it isn't.
What version of the product are you using? On what operating system?
0.1.2
Please provide any additional information below.
Hello, first I wanted to say that i like your lib. It is simple and works like a charm. Anyway, in my application I have floating windows with base data in it and I need to drag and drop it to the main area.
But, because you use the "m_DragInfo.VisualSource" to determine the adorner layer, the adorner isn't rendered on the second window (adorned layer of the first window is used).
I have an easy solution for this:
instead of:
static void DropTarget_PreviewDragOver(object sender, DragEventArgs e)
{
...
CreateDragAdorner();
}
you could use the sender of the event to determine the adorner layer:
static void DropTarget_PreviewDragOver(object sender, DragEventArgs e)
{
...
CreateDragAdorner(sender as UIElement);
}
then you need just to use that element to determine the adorner layer:
static void CreateDragAdorner(UIElement sender)
{
...
Window parentWindow = sender.GetVisualAncestor<Window>();
}
For me it works!
What do you think about that?
Thank you,
Cheers,
Andreas
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=23
Original author: [email protected] (March 30, 2011 22:46:28)
>What steps will reproduce the problem?
>What is the expected output? What do you see instead?
Sometimes it would work as expected as it does in 'Listbox with Groups' but most of the time the dropInfo.Data was a CollectionViewGroupInternal instead of a GroupedItem which caused an exception. Dragging multiple items always worked after I modified Data.Drop.
I suspect the problem maybe the DataGrid itself.
>What version of the product are you using?
Latest from subversion
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=33
Original author: [email protected] (January 12, 2010 04:57:45)
What steps will reproduce the problem?
1.Show a messagebox on the previewkeydown event of the source listbox
2. click the targretlistboxitem shows the messagebox shows somewhere
away from the target listbox
3. click ok and drag from there(the messgabebox position)
Hi,
Just found a little bug i think...I came up with a situation in which i had
to give a message box in my listbox previewkeydown event.What happens is
that,Suppose the Messagebox shows at the centre of the screen..over a plain
border..First i click the listbox(just click no drag) the message is shown
over a border.I click ok and drag from the border..Interesting it
works..and drags the clicked listbox content..
Further drag is no more possible from the target listbox...
Pls help me finding a solution to this.I can provide you a sample code to
reproduce this issue...thanks
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=3
Original author: [email protected] (December 07, 2010 14:58:50)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
The expected output would be the cloned data added to the datagrid. In the DragOver and Drop events I would handle any data issues. However, I never get that far because the Invalid tymed (Exception from HRESULT: 0x80040069 (DV_E_TYMED)) exception is raised by the O/S at line 135 in GongSolutions.Wpf.DragDrop.DropInfo.cs (code is Data = (e.Data.GetDataPresent(dataFormat)) ? e.Data.GetData(dataFormat) : e.Data;).
What version of the product are you using? On what operating system?
0.1.3 (Assembly version) - I built from source
Windows XP
Please provide any additional information below.
Exception details follow:
System.Runtime.InteropServices.COMException was unhandled by user code
Message=Invalid tymed (Exception from HRESULT: 0x80040069 (DV_E_TYMED))
Source=mscorlib
ErrorCode=-2147221399
StackTrace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at System.Windows.DataObject.System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC& formatetc, STGMEDIUM& medium)
at System.Runtime.InteropServices.ComTypes.IDataObject.GetData(FORMATETC& format, STGMEDIUM& medium)
at System.Windows.DataObject.OleConverter.GetDataInner(FORMATETC& formatetc, STGMEDIUM& medium)
at System.Windows.DataObject.OleConverter.GetDataFromOleHGLOBAL(String format, DVASPECT aspect, Int32 index)
at System.Windows.DataObject.OleConverter.GetDataFromBoundOleDataObject(String format, DVASPECT aspect, Int32 index)
at System.Windows.DataObject.OleConverter.GetData(String format, Boolean autoConvert, DVASPECT aspect, Int32 index)
at System.Windows.DataObject.OleConverter.GetData(String format, Boolean autoConvert)
at System.Windows.DataObject.GetData(String format, Boolean autoConvert)
at System.Windows.DataObject.GetData(String format)
at GongSolutions.Wpf.DragDrop.DropInfo..ctor(Object sender, DragEventArgs e, DragInfo dragInfo)
at GongSolutions.Wpf.DragDrop.DragDrop.DropTarget_PreviewDragOver(Object sender, DragEventArgs e)
at GongSolutions.Wpf.DragDrop.DragDrop.DropTarget_PreviewDragEnter(Object sender, DragEventArgs e)
at System.Windows.DragEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.OleDropTarget.RaiseDragEvent(RoutedEvent dragEvent, Int32 dragDropKeyStates, Int32& effects, DependencyObject target, Point targetPoint)
at System.Windows.OleDropTarget.MS.Win32.UnsafeNativeMethods.IOleDropTarget.OleDragOver(Int32 dragDropKeyStates, Int64 point, Int32& effects)
InnerException:
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=29
Original author: [email protected] (February 18, 2010 10:47:53)
Hi
Your Library is great!
I suggest some additional features:
The call to System.Windows.DragDrop.DoDragDrop() causes an exception when
used in partial trust (e.g. with XBAP). That means that we have to use
another mechanism for drag&drop. A solution for that can be found here:
http://blogs.claritycon.com/blogs/lee_roth/archive/2009/04/06/wpf-drag-and-
drop-between-itemscontrols.aspx
The soultion mentioned above
(http://blogs.claritycon.com/blogs/lee_roth/archive/2009/04/06/wpf-drag-
and-drop-between-itemscontrols.aspx) shows a nice effect: the
dragAdorner "jumps" back to the origin if drag-drop operation fails.
With Expression Blend 3 a new kind of customizable code arrived: Behaviors.
Changing the actual frame into a behavior might simplify usage of the code
out of designers. Example:
http://codeblitz.wordpress.com/2009/06/26/wpf-itemscontrol-drag-drop-
behavior/
What do you think about this extensions?
Best Regards,
Linus
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=7
Original author: [email protected] (February 23, 2011 19:15:51)
What steps will reproduce the problem?
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=32
Original author: [email protected] (May 21, 2010 06:45:03)
What steps will reproduce the problem?
Since I'm using MVVM I have a different ViewModel for the child element, thus also a different event handler
for dropping an element of a different type than dropped onto the parent Grid.
What is the expected output? What do you see instead?
The grid will handle the event and the dragOver event will never trigger on the child
What version of the product are you using? On what operating system?
1.1 on WinXP
Please provide any additional information below.
I circumvented this by adding a new property in DragInfo called "IsNotHandled" (inverted to apply default
behaviour in this case)
In the DragDrop class I changed the following code;
static void DropTarget_PreviewDragOver(object sender, DragEventArgs e)
{
...
e.Handled = !dropInfo.IsNotHandled; // Allows bubbling
Scroll((DependencyObject)sender, e);
}
and
static void DropTarget_PreviewDrop(object sender, DragEventArgs e)
{
...
e.Handled = !dropInfo.IsNotHandled; // Allows bubbling
}
In the handler for my Grid I've added the following code:
public void DragOver(DropInfo dropInfo)
{
if (dropInfo.Data is ButtonLayoutViewModel || dropInfo.Data is JoystickLayoutViewModel)
{
dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
dropInfo.Effects = DragDropEffects.Copy;
}
else
{
dropInfo.IsNotHandled = true; // Allows the event to bubble to the next element
}
}
This resolved my issue of allowing drop onto a child viewmodel on a viewmodel.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=15
Original author: [email protected] (June 07, 2010 17:07:43)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I expect the selection of the item to be removed but nothing happens -
selection of items cannot be removed with Ctrl+LeftMouseClick.
What version of the product are you using? On what operating system?
0.1.2 on Windows 7
Please provide any additional information below.
I really like this drag n drop implementation.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=20
Original author: [email protected] (June 28, 2011 17:10:07)
I made a quick modification to the DragDrop.CreateDragAdorner() method so that by default (when an adorner template is not specified), an image is extracted from the dragged item(s) and that is used as the adorner instead.
I'm not sure why this was never added as a feature before, it's so easy to implement...
Here is my modification to that method, plus a new helper method to do the image generation:
static void CreateDragAdorner()
{
var template = GetDragAdornerTemplate(m_DragInfo.VisualSource);
// This block was added to create a Data Template on the fly with an image generated
// from m_DragInfo.VisualSourceItem. -- Chris Bordeman [email protected]
if (template == null)
{
template = new DataTemplate();
var factory = new FrameworkElementFactory(typeof(Image));
var bs = CaptureScreen(m_DragInfo.VisualSourceItem);
factory.SetValue(Image.SourceProperty, bs);
if (m_DragInfo.VisualSourceItem is FrameworkElement)
{
factory.SetValue(FrameworkElement.WidthProperty,((FrameworkElement) m_DragInfo.VisualSourceItem).ActualWidth);
factory.SetValue(FrameworkElement.HeightProperty, ((FrameworkElement)m_DragInfo.VisualSourceItem).ActualHeight);
}
template.VisualTree = factory;
}
// The rest of the code was originally inside an "if (template != null)"
// block. -- Chris Bordeman [email protected]
UIElement rootElement = null;
Window parentWindow = m_DragInfo.VisualSource.GetVisualAncestor<Window>();
UIElement adornment = null;
if (parentWindow != null)
{
rootElement = parentWindow.Content as UIElement;
}
if (rootElement == null)
{
rootElement = (UIElement)Application.Current.MainWindow.Content;
}
if (m_DragInfo.Data is IEnumerable && !(m_DragInfo.Data is string))
{
if (((IEnumerable)m_DragInfo.Data).Cast<object>().Count() <= 10)
{
ItemsControl itemsControl = new ItemsControl();
itemsControl.ItemsSource = (IEnumerable)m_DragInfo.Data;
itemsControl.ItemTemplate = template;
// The ItemsControl doesn't display unless we create a border to contain it.
// Not quite sure why this is...
Border border = new Border();
border.Child = itemsControl;
adornment = border;
}
}
else
{
ContentPresenter contentPresenter = new ContentPresenter();
contentPresenter.Content = m_DragInfo.Data;
contentPresenter.ContentTemplate = template;
adornment = contentPresenter;
}
if (adornment != null)
{
adornment.Opacity = 0.5;
DragAdorner = new DragAdorner(rootElement, adornment);
}
}
// Helper to generate the image - I grabbed this off Google
// somewhere. -- Chris Bordeman [email protected]
private static BitmapSource CaptureScreen(Visual target, double dpiX = 96.0, double dpiY = 96.0)
{
if (target == null)
return null;
var bounds = VisualTreeHelper.GetDescendantBounds(target);
var rtb = new RenderTargetBitmap((int)(bounds.Width * dpiX / 96.0),
(int)(bounds.Height * dpiY / 96.0),
dpiX,
dpiY,
PixelFormats.Pbgra32);
var dv = new DrawingVisual();
using (var ctx = dv.RenderOpen())
{
var vb = new VisualBrush(target);
ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
}
rtb.Render(dv);
return rtb;
}
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=38
Original author: [email protected] (April 07, 2011 11:48:11)
There is an issue with the HitTestScrollBar code.
You current have the line:
hit.VisualHit.GetVisualAncestor<System.Windows.Controls.Primitives.ScrollBar>() != null;
This checks to see if the visual ancestor of the hit item is the a scroll bar. However what it doesn't check for is if its visible or not.
I've changed the version in my branch to be:
static bool HitTestScrollBar(object sender, MouseButtonEventArgs e)
{
HitTestResult hit = VisualTreeHelper.HitTest((Visual)sender, e.GetPosition((IInputElement)sender));
if (hit == null)
return false;
else
{
var scrollBar = hit.VisualHit.GetVisualAncestor<System.Windows.Controls.Primitives.ScrollBar>();
return scrollBar != null && scrollBar.Visibility == Visibility.Visible;
}
}
Without the extra visibility check the scroll bar is reporting it is being hit when it isn't visible, and therefore stops the user from dragging the item.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=34
Original author: [email protected] (June 04, 2010 13:59:15)
I added a feature to better support the TreeView with the drag and drop.
I wanted to provide you my solution maybe you can integrate it in a future
release:
First I wanted that the treeview items expanded themselves when dragging
over them. For this I added the following code to DropInfo.cs Line 63
TreeViewItem tvItem = item as TreeViewItem;
if (tvItem != null)
{
tvItem.IsExpanded = true;
}
Then there was a little problem with the Highlight Adorner because it
Highlighted not only the treenode where the mouse was over but also all its
child nodes. Found a solution but it is a bit hacky. Maybe there is a
cleaner solution for this out there. I modified the method OnRender in
DropTargetHighlightAdorner.cs to the following:
protected override void OnRender(DrawingContext drawingContext)
{
if (DropInfo.VisualTargetItem != null)
{
Rect rect;
TreeViewItem tvItem = DropInfo.VisualTargetItem as TreeViewItem;
if (tvItem != null)
{
var grid = (Grid)((UIElement)VisualTreeHelper.GetChild(DropInfo.VisualTargetItem, 0));
var descendant = VisualTreeHelper.GetDescendantBounds(DropInfo.VisualTargetItem);
rect = new Rect(DropInfo.VisualTargetItem.TranslatePoint(new Point(), AdornedElement),
new Size(descendant.Width + 4, grid.RowDefinitions[0].ActualHeight));
}
else
{
rect = new Rect(DropInfo.VisualTargetItem.TranslatePoint(new Point(), AdornedElement),
VisualTreeHelper.GetDescendantBounds(DropInfo.VisualTargetItem).Size);
}
drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Gray, 2), rect, 2, 2);
}
}
Anyway. Very nice work. Didn't found anything comparable.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=18
Original author: [email protected] (May 25, 2011 10:14:22)
Linked to issue 26, but with a complete patch.
Not sure what your final plans are.
But we are needing to drag items from controls which are not item controls.
such as DevExpress Grids, Images etc
At the moment the DragInfo was tightly couple to the Drag Source being ItemsControl.
This patch abstracts the creation of DragInfo behind a factory allowing for other IDragInfo to be created.
Factory can be set like the handler via dependency property
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=36
Original author: [email protected] (December 03, 2009 16:05:17)
Drop on a listbox with group style.
The itemscontrol.getitemcontainerat returns a null always..
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=2
Original author: [email protected] (July 08, 2010 13:16:25)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Expected: Drop fails or the cursor changes to show that dropping is not enabled on the scroll bar, no changes to the list.
Reality: Item moved to the bottom of the list.
It looks like the default drop target is the last item in the list. So when the algorithm cannot determine which item is the target, it just drops at the end of the list.
What version of the product are you using? On what operating system?
0.1.2 on Windows XP
Please provide any additional information below.
I am binding the items to the list box
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=25
Original author: [email protected] (February 12, 2010 11:16:17)
What steps will reproduce the problem?
What is the expected output? What do you see instead?
I'd expect the drag adorner to still be displayed but it doesn't.
What version of the product are you using? On what operating system?
0.1.2
Please provide any additional information below.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=6
Original author: [email protected] (September 20, 2012 02:26:51)
What steps will reproduce the problem?
var fakeDropInfo = new Mock<DropInfo>();
fakeDropInfo.SetupGet(d => d.Data).Returns(file);
fakeDropInfo.SetupGet(d => d.TargetItem).Returns(targetDataTag);
(dialog as IDropTarget).Drop(fakeDropInfo.Object);
Invalid setup on a non-virtual (overridable in VB) member: d => d.Data
What is the expected output? What do you see instead?
I think the 'DropInfo' class should be testable.
Currently it is not implementing any interface and not marked by virtual.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=48
Original author: [email protected] (July 14, 2010 02:19:05)
Download version 0.1.3 and compile under VS 2010 Express
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=27
Original author: [email protected] (May 05, 2010 14:19:18)
In DropTargetInsertionAdorner.cs you draw an insertion line where the drop
will take place (when dropped).
I think it is beter to not-draw it when drop is not allowed.
Just change:
protected override void OnRender(DrawingContext drawingContext)
{
if (DropInfo.Effects != DragDropEffects.None)
{
....
Another point is that I want to make use of a TreeView and I think we need
a bit different approach here. There is a distinction between dropping on
an treenode and between nodes. Is it possible to mark (based on a
template?) an item instead of a line in that case? I would suggest a couple
of pixels from the top/left and bottom/right would indicate an insertion
and otherwise a drop on that item. You might ask the DragOver what to do.
What do you think about it?
Frank
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=13
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.