A newer version of this page is available. Switch to the current version.

TreeMapColorizerBase.GetItemColor(TreeMapItem, TreeMapItemGroupInfo) Method

Returns the color for the specified item with the specified tree location.

Namespace: DevExpress.Xpf.TreeMap

Assembly: DevExpress.Xpf.TreeMap.v20.2.dll


public abstract Color? GetItemColor(
    TreeMapItem item,
    TreeMapItemGroupInfo group


Name Type Description
item TreeMapItem

A TreeMapItem object for which the color is obtained.

group TreeMapItemGroupInfo

A TreeMapItemGroupInfo value specifying information about the item position in a group.


Type Description

A nullable Color value that is the color of the specified item.


To implement the custom colorizer, inherit the TreeMapColorizerBase or its descendant class, and override the TreeMapColorizerBase.GetItemColor method. Sent as parameters, the TreeMapItem and TreeMapItemGroupInfo objects contain all the required information to colorize items.

View Example

Imports DevExpress.Xpf.TreeMap
Imports System.Windows.Media

Namespace CustomColorizerSample
    Friend Class CustomColorizer
        Inherits TreeMapPaletteColorizerBase

        Public Overrides Function GetItemColor(ByVal item As TreeMapItem, ByVal group As TreeMapItemGroupInfo) As Color?
            If item.Children.Count = 0 Then
                Dim itemColor As Color = Palette(group.ItemIndex Mod Palette.Count)
                Dim groupColor As Color = Palette(group.GroupIndex Mod Palette.Count)
                Dim proportion As Double = (item.Value - group.MinValue) / (group.MaxValue - group.MinValue)

                Return New Color With {.A = 255, .R = CByte(proportion * itemColor.R + (1-proportion)*groupColor.R), .G = CByte(proportion * itemColor.G + (1 - proportion) * groupColor.G), .B = CByte(proportion * itemColor.B + (1 - proportion) * groupColor.B)}
                Return Palette(Palette.Count - 1 - group.GroupLevel Mod Palette.Count)
            End If
        End Function

        Protected Overrides Function CreateObject() As TreeMapDependencyObject
            Return New CustomColorizer()
        End Function
    End Class
End Namespace
See Also