New to Telerik UI for WPFStart a free 30-day trial

Removing Connected Connections on Item Deletion in RadDiagram

Updated on Sep 15, 2025

Environment

ProductRadDiagram for WPF
Version2023.3.1114

Description

How to remove attached RadDiagramConnections when the associated diagram shape is deleted.

Solution

To do this, you can use the RadDiagram's ItemsChanging event. In the event handler, you can access the deleted shape and remove its connections from the diagram. To access the connections attached to the shape, you can use the IncomingLinks and OutgoingLinks properties of the shape.

C#
	private void RadDiagram_ItemsChanging(object sender, Telerik.Windows.Controls.Diagrams.DiagramItemsChangingEventArgs e)
	{
		if (e.OldItems.Count() > 0)
		{
			var diagram = (RadDiagram)sender;
			var shapes = e.OldItems.OfType<RadDiagramShapeBase>();
			foreach (var shape in shapes)
			{
				foreach (var connection in shape.IncomingLinks.ToList())
				{
					diagram.RemoveConnection(connection, true);
				}

				foreach (var connection in shape.OutgoingLinks.ToList())
				{
					diagram.RemoveConnection(connection, true);
				}
			}
		}
	}
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support