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. |
|
RoutedEvent |
NodeLabelChanged |
Raised when the Node's label value is changed. This event cannot be cancelled. |
|
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. |
|
RoutedEvent |
ConnectorStartLabelEdit |
Raised when the label editing for the Connector has started. This event cannot be cancelled. |
|
RoutedEvent |
ConnectorLabelChanged |
Raised when the Connector's label value is changed. This event cannot be cancelled. |
|
RoutedEvent |
ConnectorDragStart |
Raised when either end of the Connector is dragged. This event cannot be cancelled. |
|
RoutedEvent |
ConnectorDragEnd |
Raised when the drag operation is completed. This event cannot be cancelled. |
|
RoutedEvent |
NodeDrop |
Raised when a shape from SymbolPalette is dropped on a page. This event cannot be cancelled. |
|
RoutedEvent |
HeadNodeChanged |
Raised when the HeadNode of the Connector is changed. This event cannot be cancelled. |
|
RoutedEvent |
TailNodeChanged |
Raised when the TailNode of the Connector is changed. This event cannot be cancelled. |
|
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. |
|
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. |
|
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.
<sfdiagram:DiagramView Name="diagramView" NodeClick="diagramView_NodeClick">
</sfdiagram:DiagramView>
diagramView.NodeClick += new NodeEventHandler(diagramView_NodeClick);
AddHandler diagramView.NodeClick, AddressOf diagramView_NodeClick
Then, the event handler can be specified in code behind, as shown in the following code snippet.
// The event handler.
void diagramView_NodeClick(object sender, NodeRoutedEventArgs evtArgs)
{
// User specified code.
}
'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.
<sfdiagram:DiagramView Name="diagramView" ConnectorDoubleClick="diagramView_ConnectorDoubleClick">
</sfdiagram:DiagramView>
diagramView.ConnectorDoubleClick += new ConnChangedEventHandler(diagramView_ConnectorDoubleClick);
AddHandler diagramView.ConnectorDoubleClick, AddressOf diagramView_ConnectorDoubleClick
Then, the event handler can be specified in code behind, as shown in the following code snippet.
// The event handler.
void diagramView_ConnectorDoubleClick(object sender, ConnRoutedEventArgs evtArgs)
{
// User specified code.
}
'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.
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)
{
}
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
Sample Link
To view a sample:
- Open the Diagram Sample Browser from the dashboard. (Refer to the Samples and Location chapter.)
- Navigate to Product Showcase -> Features Demo.