This is a migrated thread and some comments may be shown as answers.

Prevent connection update when node is (not) deleted

2 Answers 91 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Matthias
Top achievements
Rank 1
Matthias asked on 01 Jun 2017, 05:34 AM

My diagram has a mode in which nodes can be selected, but cannot be deleted. The deletion request is denied with a user message explaining what happened. Because I'm using a MVVM setup, I'm overriding RemoveItem in my GraphSource like so:

public override bool RemoveItem(DisplayNode node)
{
    if (m_MainVM.NoDeleteAllowed)
        return false;
 
    return base.RemoveItem(node);  
}

That works as expected, BUT: any connections to/from the node that is not actually getting deleted have already been updated with null references when I reach this part of the code. The Source or Target property of those RadDiagramConnections has been set to null where the node was referenced before. Obviously that's not what I want since the node is not actually getting deleted.

Where do I handle this behavior and prevent it? The RadDiagram events don't seem to catch this case. I could reconstruct the RadDiagramConnection's Source or Targets, I guess. But that seems like a hack.

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 05 Jun 2017, 02:15 PM
Hi Matthias,

Can you try the AllowDelete property of the diagram and see if it works for you?
<telerik:RadDiagram AllowDelete="False" />
Setting the property to False will prevent you to delete nodes when you press the Delete key. There is AllowDelete property also in the RadDiagramItem (shape, connection, container) class.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Matthias
Top achievements
Rank 1
answered on 07 Jun 2017, 02:15 PM
Thanks. I wasn't aware of all these Allow properties, and they allow me to do what I wanted to do without intercepting the delete :)
Tags
Diagram
Asked by
Matthias
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Matthias
Top achievements
Rank 1
Share this question
or