Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Data Binding on the AllowDrop property in DiagramNode (Read 1954 times)
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Data Binding on the AllowDrop property in DiagramNode
Jun 4th, 2021 at 7:35am
Print Post  
Hello,

I was tasked at work to implement a drag&drop operation from one place in our application into one of the DiagamNodes. What I have noticed is that every node has the AllowDrop property data binding set without ever specifying the binding myself.

Is this something that is set and used internally in the Diagram component and if so, is there a way I can work around it and implement the d&d operation?

Thanks for your help,
JL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Data Binding on the AllowDrop property in DiagramNode
Reply #1 - Jun 4th, 2021 at 7:56am
Print Post  
Hi,

It is indeed bound to diagram's AllowDrop. You could remove the binding by calling System.Windows.Data.BindingOperations.ClearBinding, or just process the node from diagram's own events:

Code
Select All
void OnDiagramDragOver(object sender, DragEventArgs e)
{
    var position = e.GetPosition(diagram.DocumentPlane);
    var node = diagram.GetNodeAt(position);
    if (node == thatSpecificNode)
        e.Effects = DragDropEffects.Copy;
    else
        e.Effects = DragDropEffects.None;
    e.Handled = true;
}

void OnDiagramDrop(object sender, DragEventArgs e)
{
    var position = e.GetPosition(diagram.DocumentPlane);
    var node = diagram.GetNodeAt(position);
    if (node == thatSpecificNode)
    {
        e.Effects = DragDropEffects.Copy;
        node.Text = (string)e.Data.GetData(typeof(string));
    }
    e.Handled = true;
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Re: Data Binding on the AllowDrop property in DiagramNode
Reply #2 - Jun 4th, 2021 at 8:15am
Print Post  
Let's say I go with clearing the binding manually. Would this potentially break any functionality of the Diagram itself?

Another question, when is the binding being set? I noticed that during the initialization of the DiagramNode the binding is still not set (and not clearable), not even during the OnRender call.

Is there an extensibility point that I can use to access the property after it's been initialized?

Thanks for the fast answer!
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Data Binding on the AllowDrop property in DiagramNode
Reply #3 - Jun 4th, 2021 at 8:24am
Print Post  
It's bound mostly to let the diagram receive these drag and drop events at any position once you enable its own property, otherwise nodes with disabled AllowDrop prevent it. We can't think of adverse effects from unbinding the node if you don't care about handling drag and drop for the whole diagram. The binding is created when node is added as diagram's child element, e.g. try clearing from ItemAdded or NodeCreated event handler.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Re: Data Binding on the AllowDrop property in DiagramNode
Reply #4 - Jun 4th, 2021 at 10:00am
Print Post  
Ok, thank you very much for your helpful answers.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint