Back to Devexpress

Highlighting and Selection

wpf-115041-controls-and-libraries-treemap-control-end-user-interaction-highlighting-and-selection.md

latest2.2 KB
Original Source

Highlighting and Selection

  • Aug 19, 2020

The TreeMap control supports item highlighting and selection.

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

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

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.

xaml
<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.

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

void OnSelectionChanged(object sender, TreeMapSelectionChangedEventArgs e) {
    // Perform actions that should be done when selection changes.
}
vb
' ...
AddHandler treeMap.SelectionChanged, AddressOf OnSelectionChanged
' ...

Sub OnSelectionChanged(sender As Object, e As TreeMapSelectionChangedEventArgs)
    ' Perform actions that should be done when selection changes.
End Sub

See Also

How to: Configure Highlighting and Selection