Event Mechanism

This section describes the events that are triggered and handled when using Essential Diagram Silverlight.

Events for Nodes and Connections

DiagramControl has events, which respond to actions performed on nodes and connections.

Event Table

The events that are triggered and handled when using Essential Diagram Silverlight are described in the following tabulation:

Event Description Arguments Type
NodeClick Raised when the Node is clicked.
This event cannot be cancelled.
Node - The Node on which the event is raised. RoutedEvent
NodeDoubleClick Raised when the Node is double-clicked.
This event cannot be cancelled.
Node - The Node on which the event is raised. RoutedEvent
NodeStartLabelEdit Raised when the label editing for the Node has started.
This event cannot be cancelled.
  • NewLabelValue - The new label value.
  • OldLabelValue - The old label value
  • Node - The Node on which the event is raised.
RoutedEvent
NodeLabelChanged Raised when the Node's label value is changed.
This event cannot be cancelled.
  • NewLabelValue - The new label value.
  • OldLabelValue - The old label value.
  • Node - The Node on which the event is raised.
RoutedEvent
NodeDragStart Raised when the Node is dragged.
This event cannot be cancelled.
Node - The Node on which the event is raised. RoutedEvent
NodeDragEnd Raised when the drag operation on the Node is completed.This event cannot be cancelled. Node - The Node on which the event is raised. RoutedEvent
NodeResizing Raised when the resize operation is being performed.
This event cannot be cancelled.
Node - The Node on which the event is raised. RoutedEvent
NodeResized Raised after the Node is resized.
This event cannot be cancelled.
Node - The Node on which the event is raised. RoutedEvent
NodeRotationChanging Raised when the Node is being rotated.
This event cannot be cancelled.
Node - The Node on which the event is raised. RoutedEvent
NodeRotationChanged Raised after the Node is rotated.
This event cannot be cancelled.
Node - The Node on which the event is raised. RoutedEvent
ConnectorDoubleClick Raised when the Connector is double-clicked.
This event cannot be cancelled.
  • Connector - The Connector on which the event is raised.
  • HeadNode - The HeadNode of the Connector.
  • TailNode - The TailNode of the Connector.
RoutedEvent
ConnectorStartLabelEdit Raised when the label editing for the Connector has started.
This event cannot be cancelled.
  • Connector - The Connector on which the event is raised.
  • HeadNode - The HeadNode of the Connector.
  • TailNode - The TailNode of the Connector.
  • OldLabelValue - The old label value.
RoutedEvent
ConnectorLabelChanged Raised when the Connector's label value is changed.
This event cannot be cancelled.
  • Connector - The Connector on which the event is raised.
  • HeadNode - The HeadNode of the Connector.
  • TailNode - The TailNode of the Connector.
  • OldLabelValue - The old label value.
  • NewLabelValue - The new label value.
RoutedEvent
ConnectorDragStart Raised when either end of the Connector is dragged.
This event cannot be cancelled.
  • Connector - The Connector on which the event is raised.
  • FixedNodeEnd - The Node on which the Connector is fixed.
  • MovableNodeEnd - The old Node on which the Connector was connected.
RoutedEvent
ConnectorDragEnd Raised when the drag operation is completed.
This event cannot be cancelled.
  • Connector - The Connector on which the event is raised.
  • FixedNodeEnd - The Node on which the Connector is fixed.
  • HitNodeEnd - The new Node on which the Connector is getting connected.
RoutedEvent
NodeDrop Raised when a shape from SymbolPalette is dropped on a page.
This event cannot be cancelled.
  • DroppedNode - The new Node that is dropped from SymbolPalette.
  • SymbolPaletteItemName - The name of the SymbolPalette item, which is dropped on a page.
RoutedEvent
HeadNodeChanged Raised when the HeadNode of the Connector is changed.
This event cannot be cancelled.
  • Connector - The Connector for which the HeadNode is changed.
  • PreviousNode - The old Node on which the HeadNode of the Connector was connected.
  • CurrentNode - The new Node on which the HeadNode of the Connector is connected.
RoutedEvent
TailNodeChanged Raised when the TailNode of the Connector is changed.
This event cannot be cancelled.
  • Connector - The Connector for which the HeadNode is changed.
  • PreviousNode - The old Node on which the TailNode of the Connector was connected.
  • CurrentNode - The new Node on which the TailNode of the Connector is connected.
RoutedEvent
ConnectorDrop Raised when the Connector is dropped on a page.
This event cannot be cancelled.
DroppedConnector - The Connector on which the event is raised. RoutedEvent
BeforeConnectionCreate Raised when a new connection is being made.
This event cannot be cancelled.
Connector - The Connector for which the HeadNode is changed. RoutedEvent
AfterConnectionCreate Raised after the connection is made.
This event cannot be cancelled.
  • Connector - The Connector on which the event is raised.
  • FixedNodeEnd - The Node on which the Connector is fixed.
  • HitNodeEnd - The new Node on which the Connector is getting connected.
RoutedEvent
NodeSelected Raised when a Node is selected.
This event cannot be cancelled.
Node - The Node on which the event is raised. RoutedEvent
NodeUnSelected Raised when a Node is not selected.
This event cannot be cancelled.
Node - The Node on which the event is raised. RoutedEvent
NodeDeleting Raised before a Node is deleted from the model.
This event cannot be cancelled.
DeletedNode - The Node, which is going to be deleted. RoutedEvent
NodeDeleted Raised when a Node is deleted from the model.
This event cannot be cancelled.
DeletedNode - The Node, which is deleted. RoutedEvent
ConnectorDeleting Raised before a LineConnector is deleted from the model.
This event cannot be cancelled.
DeletedLineConnector - The LineConnector, which is being deleted. RoutedEvent
ConnectorDeleted Raised when a LineConnector is deleted from the model.
This event cannot be cancelled.
DeletedLineConnector - The LineConnector, which is deleted. RoutedEvent
PreviewNodeDrop Raised before a Node is dropped on a page.
This event cannot be cancelled.
Node – The Node on which the event is raised. RoutedEvent
PreviewConnectorDrop Raised before a Connector is dropped on a page.
This event cannot be cancelled.
Connector – The Connector on which the event is raised. RoutedEvent
NodeMoved(Event is fired before the nudge operation is completed.) Raised when the nudge operation on the Node is completed.
This event cannot be cancelled.
  • Node – The Node on which the event is raised.
  • oldOffset – The old offset value before the nudge operation.
  • newOffset – The new offset value after performing the nudge operation.
RoutedEvent
ConnectorClick Raised when a connector is clicked. This event cannot be canceled. LineConnector – The line connector on which the event is raised. Routed Event
ConnectorSelected Raised when a connector is selected.This event cannot be canceled. LineConnector – The line connector on which the event is raised. Routed Event
LineMoved Raised when a line connector is moved.This event cannot be canceled. LineConnector – The line connector on which the event is raised. Routed Event
PropetyChanged Raised when the dependency property is changed.This event cannot be canceled. DependencyObject –The object on which the event is raised. Routed Event
NodeDragging Raised when the node is dragging.This event cannot be canceled. Node – The node on which the event is raised. Routed Event
Grouped Raised when elements in the diagram page are grouped.This event cannot be canceled. Group – The group in which the event is raised. Routed Event
UnGrouped Raised when elements in the diagram page are ungrouped. This event cannot be canceled. Group – The group in which the event is raised. Routed Event
Grouping Raised when elements in the diagram page are being grouped. This event cannot be canceled. Group – The Group in which the event is raised. Routed Event
UnGrouping Raised when elements in diagram page are being ungrouped. This event cannot be canceled. Group – The group in which the event is raised. Routed Event

Examples: 

The events that are triggered and handled while using Essential Diagram for Silverlight can be specified by using the DiagramView object, as shown in the following examples:

The NodeClick event can be specified, as shown in the following code snippets.

  • xaml
  • <sfdiagram:DiagramView Name="diagramView" NodeClick="diagramView_NodeClick">
    
    </sfdiagram:DiagramView>
  • c#
  • diagramView.NodeClick += new NodeEventHandler(diagramView_NodeClick);
  • vbnet
  • AddHandler diagramView.NodeClick, AddressOf diagramView_NodeClick

    Then, the event handler can be specified in code behind, as shown in the following code snippet.

  • c#
  • // The event handler.
    
    void diagramView_NodeClick(object sender, NodeRoutedEventArgs evtArgs)
    
    {
    
    // User specified code.
    
    }
  • vbnet
  • 'The event handler.
    
        Private Sub diagramView_NodeClick(ByVal sender As Object, ByVal evtArgs As NodeRoutedEventArgs)
    
    'User specified code.
    
    End Sub

    The ConnectorDoubleClick event can be specified, as shown in the following code snippets.

  • xaml
  • <sfdiagram:DiagramView Name="diagramView" ConnectorDoubleClick="diagramView_ConnectorDoubleClick">
    
    </sfdiagram:DiagramView>
  • c#
  • diagramView.ConnectorDoubleClick += new ConnChangedEventHandler(diagramView_ConnectorDoubleClick);
  • vbnet
  • AddHandler diagramView.ConnectorDoubleClick, AddressOf diagramView_ConnectorDoubleClick

    Then, the event handler can be specified in code behind, as shown in the following code snippet.

  • c#
  • // The event handler.
    
    void diagramView_ConnectorDoubleClick(object sender, ConnRoutedEventArgs evtArgs)
    
    {
    
    // User specified code.
    
    }
  • vbnet
  • 'The event handler.
    
    Private Sub diagramView_ConnectorDoubleClick(ByVal sender As Object, ByVal evtArgs As ConnRoutedEventArgs)
    
    'User specified code.
    
    End Sub

    The NodeMoved and NodeDrop events can be specified, as shown in the following code snippet.

  • c#
  • diagramView.NodeMoved += new NodeNudgeEventHandler(diagramView_NodeMoved);
    
    void diagramView_NodeMoved(object sender, NodeNudgeEventArgs evtArgs)
    
    {
    
    }
    
    diagramView.NodeDrop += new NodeNudgeEventHandler(diagramView_LineMoved);
    
    void diagramView_NodeDrop(object sender, NodeNudgeEventArgs evtArgs)
    
    {
    
    }
  • vbnet
  • Private diagramView.NodeMoved += New NodeNudgeEventHandler(AddressOf diagramView_NodeMoved)
    
    Private Sub diagramView_NodeMoved(ByVal sender As Object, ByVal evtArgs As NodeNudgeEventArgs)
    
    End Sub
    
    
    Private diagramView.NodeDrop += New NodeNudgeEventHandler(AddressOf diagramView_LineMoved)
    
    Private Sub diagramView_NodeDrop(ByVal sender As Object, ByVal evtArgs As NodeNudgeEventArgs)
    
    End Sub

    To view a sample:

    1. Open the Diagram Sample Browser from the dashboard. (Refer to the Samples and Location chapter.)
    2. Navigate to Product Showcase -> Features Demo.