Skip to main content

Highlighting and Selection

The TreeMap control supports item highlighting and selection.

To enable (or disable) tree map item highlighting, set the TreeMapControl.EnableHighlighting property to true (false).

TreeMapControl_EnableHighlighting

To configure selection mode, specify the TreeMapControl.SelectionMode property.

TreeMapControl_SelectionMode

The Tree Map control allows you to specify or obtain the selected item using code. To do this, use the TreeMapControl.SelectedItem property or the TreeMapControl.SelectedItems collection if SelectionMode equals to Multiple or Extended.

<TextBlock Text="{Binding ElementName=treeMap, Path=SelectedItem.Name, StringFormat=Country Name: {0}}"/>
<TextBlock Text="{Binding ElementName=treeMap, Path=SelectedItem.Gdp, StringFormat=Gdp: {0:C0}B}"/>

To perform actions when item selection changes, handle the TreeMapControl.SelectionChanged event.

// ...
treeMap.SelectionChanged += OnSelectionChanged;
// ...

void OnSelectionChanged(object sender, TreeMapSelectionChangedEventArgs e) {
    // Perform actions that should be done when selection changes.
}
See Also