Version

Show Hide Nodes

Introduction

The xamNetworkNode control currently supports three ways to show and hide child nodes:

  • Show/Hide using the Expansion indicator

  • Show/Hide without Expansion indicator, using code behind

  • Enter key on the keyboard (when expansion indicators are visible)

In addition to the default modes, any node can hide itself by setting the node’s Visibility property to “Collapsed”.

The operation of hiding and showing a child node is controlled by the connected parent node by:

  1. Using Expansion indicator

    1. With Mouse click on expansion indicators

    2. With Enter key on the keyboard while the expansion indicator is visible

  2. Using IsExpanded property in code behind, while expansion indicators are disabled

    Setting the IsExpanded property.

    Options: [Visible | Collapsed | Hidden]

  3. Data Source

    Any object that implements IEnumerable (e.g. List, Collection, etc.).

Requirements

To begin, please read the Getting Started with xamNetworkNode topic as this tutorial uses the code from the "Getting Started" topic as a starting point.

In addition, a few properties must be set in order to achieve the desired functionality.

Properties to set on xamNetworkNode:

  • ExpansionIndicatorVisibility – [Visible | Collapsed]. The following priority will take place from highest to lowest when specified:

    1. Node with expansion indicators (1st priority)

    2. Node Layout (2nd priority)

    3. XamNetworkNode globally (3rd priority)

    Note
    Note:

    ExpansionIndicatorVisibility supports null value, and when it is set to null, the lower priority will apply, for example if the ExpansionIndicatorVisibility property is set to null on the control, the lower priority (2nd) will apply, and if the 2nd priority is set to null then the 3rd priority will apply.

Properties to set on NetworkNodeNode:

  • IsExpanded – [true | false]

    Note
    Note:

    While the Expansion indicators are visible, the Enter key on the keyboard can also be used to Show/Hide the child nodes.

Configure the Show/Hide Node Settings

Show / Hide with Expansion Indicators

The following code example and the screenshot demonstrate enabling expansion indicator on the NetworkNode control for using the plus/minus symbol to show/hide children of the node. While the expansion indicator is enabled, the Enter key on the keyboard can also be used to Show/Hide the children of the selected node.

In XAML:

<ig:XamNetworkNode
    ExpansionIndicatorVisibility="Visible">
</ig:XamNetworkNode>

In Visual Basic:

node.ExpansionIndicatorVisibility = Visibility.Visible

In C#:

node.ExpansionIndicatorVisibility = Visibility.Visible;

The Figure 1 displays the xamNetworkNode with expansion indicators enabled on the parent node. The parent nodes have connections to the child nodes that can be shown and hidden. The plus sign indicates that the child nodes are hidden.

Note
Note:

There are restrictions that apply when child nodes are not hidden. For example, when a child node has two parent nodes and one of the parents is collapsed, the child node is not hidden because the other parent is not hidden. If both parents are collapsed, then the child node is hidden.

xamNetworkNode ShowHide Nodes 01.png

Figure 1: Hiding/Showing the nodes with expansion indicators.

Show / Hide without Expansion Indicators

Use the IsExpanded property of the NetworkNode control (in code behind) to Show/Hide the children of a selected node. Note that since the XamNetworkNode does not expose the Node object in XAML, the node expansion needs to be implemented in code behind.

In Visual Basic:

node.IsExpanded = true

In C#:

node.IsExpanded = True;

Figure 2 shows the selected node about to be hidden using code behind by setting IsExpanded property. The selected node has three child nodes.

xamNetworkNode ShowHide Nodes 02.png

Figure 2: Hiding/Showing nodes in code behind without expansion indicators.

Figure 3 shows the parent node from above, hiding its three children. You may also notice that the location of the node is changed.

The reason for the control to rearrange the nodes is because xamNetworkNode recalculates the nodes after changes being made and displays with an optimum layout positioning in the view.

xamNetworkNode ShowHide Nodes 03.png

Figure 3: Nodes rearanged after Hiding/Showing operation.