As you're binding the RadDiagram GraphSource to a business collection and you want to add/remove items out of it, we recommend deriving the business collection from either the ObservableGraphSourceBase<TNode,TLink>
or the SerializableGraphSourceBase<TNode, TLink>
class. Both of these classes will allow you to override the RemoveLink
method which is triggered when a link is removed from the RadDiagram
collection of items. You can use this method to cancel the delete by returning a false value in it.
The SerializableGraphSourceBase<TNode, TLink>
class is the better choice when you need to copy/paste the Shapes/Connections of the diagram along with their databound content. As by default the RadDiagram serialization mechanism serializes the list of properties described here
, it doesn't serialize the DataContext of the items and this is why when you bind the content of the shapes/connections, a copy/paste operation won't keep the binded content. This is why we've provided the SerializableGraphSourceBase<TNode, TLink>
class - if your GraphSource
collection derives from it, you can override the SerializeNode/Link
methods to manually serialize the business properties that you need.
I attached a sample solution demonstrating how to derive the GraphSource
collection from the SerializableGraphSourceBase<TNode, TLink>
class. Please note you need to layout the RadDiagram
to see the full structure of the databound diagram through the Layout
button. And I've overriden the RemoveLink()
method to cancel the delete of a link. Let me know if that helps.
the Telerik team