Why is RadDiagram generating a drag and drop operation when it's disabled?

3 Answers 32 Views
Diagram
Pete
Top achievements
Rank 1
Iron
Iron
Iron
Pete asked on 29 Jul 2021, 09:49 AM | edited on 29 Jul 2021, 10:34 AM

I'm getting a crash:

System.ArgumentNullException
  HResult=0x80004003
  Message=Value cannot be null.
Parameter name: dataObject
  Source=Telerik.Windows.Controls.Diagrams
  StackTrace:
    at Telerik.Windows.Controls.Diagrams.DataTransferService.HandleDiagramElementDrop(DataObject dataObject)

looking up the stack I can see:

Telerik.Windows.Controls!Telerik.Windows.DragDrop.DragDropManager.DoDragDrop(System.Windows.DependencyObject dragSource, object data, System.Windows.DragDropEffects allowedEffects, System.Windows.DragDropKeyStates initialKeyState, object dragVisual, System.Windows.Point relativeStartPoint, System.Windows.Point dragVisualOffset)

However, I didn't do a drag and drop, I did a double click on a combo box. Plus the RadDiagram has AllowDrop="False". What's going on here?

I did try to put together a sample to see if I can reproduce this but can't seem to get RadDiagram to appear (see link)

3 Answers, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 30 Jul 2021, 12:40 PM

Hello Pete,

I have provided an answer to your question, in the other forum. Follow up there in case you want to include any other information.

 Diagram sample in UI for WPF | Telerik Forums

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Pete
Top achievements
Rank 1
Iron
Iron
Iron
answered on 02 Aug 2021, 09:03 AM

I've not been able to produce a sample to demonstrate the crash, however I have been able to add code that appears to prevent the crash:


DragDropManager.AddDropHandler(xDiagram, OnDiagramDrop);

...

private void OnDiagramDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
	// Not expecting ANY drop operation on the control, so say we've handled it
	// This prevents the following crash:
	// Value cannot be null at Telerik.Windows.Controls.Diagrams.DataTransferService.HandleDiagramElementDrop(DataObject dataObject)
	// This still happens even though the control has AllowDrop="False"
	e.Handled = true;
}

I reasoned that adding a handler might help, put a trace statement initially and it always appeared just before the crash. So I wondered if handling the crash would help and so far it seems to be working.

That leaves me with a couple of questions:

  • why is double click being seen as drag and drop?
  • why is the diagram responding at all to drag and drop when drop is disabled with AllowDrop = "False"?
0
Stenly
Telerik team
answered on 05 Aug 2021, 08:43 AM

Hello Pete,

The diagram responds to drags and drops, because it does not use the WPF drag and drop operations. The RadDiagram control uses our own custom service, that on its side, uses mouse events for dragging and dropping inside the diagram. That is why the AllowDrop property, even though is set to False, won't make a change. The following article explains explains in depth the service that the RadDiagram control uses:

WPF Diagram | Services | Telerik UI for WPF

In addition, if you want to stop the shapes from being dragged, you can set the IsDraggingEnabled property of RadDiagram to False.

Regarding the exception, I could not reproduce it on my end, but I am glad that you have come up with a solution.

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Diagram
Asked by
Pete
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Pete
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or