Version

Node Selection Behaviors

This topic introduces the node selection behaviors supported by the xamOrgChart™ and demonstrates how to configure them in code.

Note
Note:

This topic uses the Org Chart created in Adding xamOrgChart to Your Application.

Selection Behaviors

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.

Note
Note:

Selection can be performed also with the Space key.

A selected node can be unselected by clicking on it while holding down the Ctrl key.

xamOrgChart Node Selection Behaviors 01.png

Figure 1: A selected node

Configuring the Selection Behavior

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">

Working with Selected Nodes

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:

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;
}