We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to apply colors based on the ColorValuePath to a LeafTemplate in SfTreeMap?

Platform: WPF |
Control: SfTreeMap |
Published Date: February 18, 2015 |
Last Revised Date: June 25, 2019

You can provide colors based on the ColorValuePath to a LeafTemplate by using MappedColor property and you can add any colormapping for leafnode using “LeafColorMapping” property.

XAML

<syncfusion:SfTreeMap.LeafColorMapping>
<syncfusion:RangeBrushColorMapping>
<syncfusion:RangeBrushColorMapping.Brushes>
<syncfusion:RangeBrush Color="#77D8D8" From="0" To="2" />
. . .
</syncfusion:RangeBrushColorMapping.Brushes>
</syncfusion:RangeBrushColorMapping>
</syncfusion:SfTreeMap.LeafColorMapping>

Use MappedColor API as binding path in Leaftemplate to bind the set of provided colors using LeafColorMapping based on ColorValuePath.

XAML

<syncfusion:SfTreeMap.LeafTemplate>
. . .
<Border Background="{Binding MappedColor}" >
. . .
</Border>
. . .
</syncfusion:SfTreeMap.LeafTemplate>

Sample Location:

TreeMapCustomization.zip

XAML

<syncfusion:SfTreeMap>
. . .
<syncfusion:SfTreeMap.LeafColorMapping>
<syncfusion:RangeBrushColorMapping>
<syncfusion:RangeBrushColorMapping.Brushes>
<syncfusion:RangeBrush Color="#77D8D8" From="0" To="2" />
<syncfusion:RangeBrush Color="#AED960" From="3" To="8" />
<syncfusion:RangeBrush Color="#FFAF51" From="9" To="11" />
<syncfusion:RangeBrush Color="#F3D240" From="12" To="16" />
</syncfusion:RangeBrushColorMapping.Brushes>
</syncfusion:RangeBrushColorMapping>
</syncfusion:SfTreeMap.LeafColorMapping>
. . .
<syncfusion:SfTreeMap.LeafTemplate>
<DataTemplate>
<Border BorderBrush="Transparent" BorderThickness="2" Background="{Binding MappedColor}" >
. . .
</Border>
</DataTemplate>
</syncfusion:SfTreeMap.LeafTemplate>
. . .
</syncfusion:SfTreeMap>

The following screenshot illustrates the output.

Leaf template colors using mapped color In SfTreeMap control

Figure 1: LeafTemplate colors using mappedcolor

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon