This topic introduces the node selection behaviors supported by the xamOrgChart™ and demonstrates how to configure them in code.
The xamOrgChart control supports the following selection behaviors:
none – the nodes cannot selectable
single – only one node can be selected at a time
multiple – several nodes can be selected at a time by holding down the Ctrl or Shift keys
extended – selects a node and all its child nodes. Clicking with the left mouse button toggles the selection of a branch.
A selected node can be unselected by clicking on it while holding down the Ctrl key.
Figure 1: A selected node
The selection behavior is configured through the SelectionType property of the xamOrgChart control. The valid values are None, Single, Multiple and Extended. Each of them configures the respective behavior described above.
In XAML:
<ig:XamOrgChart SelectionType="None|Single|Multiple|Extended">
The xamOrgChart control’s SelectedNodes property returns a collection with the currently selected nodes.
Whenever the selection changes, the SelectedNodesCollectionChanged event is raised. This event passes an OrgChartNodeSelectionEventArgs object that contains the following information:
OriginalSelectedNodes – a collection with the previously selected nodes;
CurrentSelectedNodes – a collection containing the currently selected nodes.
Attaching an event handler to the SelectedNodesCollectionChanged event:
In XAML:
<ig:XamOrgChart NodeSelection="Multiple" SelectedNodesCollectionChanged="SelectedNodesChanged">
In Visual Basic:
Private Sub SelectedNodesChanged (sender As Object, e As OrgChartNodeSelectionEventArgs) Dim originalSelectedNodes = e.OriginalSelectedNodes Dim currentSelectedNodes = e.CurrentSelectedNodes End Sub
In C#:
private void SelectedNodesChanged(object sender, OrgChartNodeSelectionEventArgs e) { var originalSelectedNodes = e.OriginalSelectedNodes; var currentSelectedNodes = e.CurrentSelectedNodes; }