16 Oct 202424 minutes to read
To make the migration from the Xamarin SfTreeMap to the .NET MAUI SfTreeMap easier, most of the APIs from the Xamarin SfTreeMap to the .NET MAUI SfTreeMap were kept in the .NET MAUI SfTreeMap. However, to maintain the consistency of API naming in the .NET MAUI SfTreeMap, some of the APIs have been renamed. Please find the difference in the following topics.
Namespaces
Xamarin SfTreeMap |
.NET MAUI SfTreeMap |
Syncfusion.Xamarin.SfTreeMap |
Syncfusion.Maui.TreeMap |
Initialize Control
To initialize the control, import the treeMap control namespace and initialize the SfTreeMap as shown in the following code sample.
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
<ContentPage
...
xmlns:treemap="clr-namespace:Syncfusion.SfTreeMap.XForms;assembly=Syncfusion.SfTreeMap.XForms">
<treemap:SfTreeMap x:Name="treeMap"/>
</ContentPage>
using Syncfusion.SfTreeMap.XForms;
...
SfTreeMap treeMap = new SfTreeMap();
this.Content = treeMap;
|
<ContentPage
...
xmlns:treemap="clr-namespace:Syncfusion.Maui.TreeMap;assembly=Syncfusion.Maui.TreeMap">
<treemap:SfTreeMap x:Name="treeMap"/>
</ContentPage>
using Syncfusion.Maui.TreeMap;
...
SfTreeMap treeMap = new SfTreeMap();
this.Content = treeMap;
|
Classes
Properties
SfTreeMap
The following code example, explains how to initialize the properties of the .NET MAUI SfTreeMap class.
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
<treemap:SfTreeMap x:Name="treeMap"
DataSource="{Binding PopulationDetails}"
PrimaryValuePath="Population">
<treemap:SfTreeMap.BindingContext>
<local:PopulationViewModel />
</treemap:SfTreeMap.BindingContext>
</treemap:SfTreeMap>
SfTreeMap treeMap = new SfTreeMap();
PopulationViewModel viewModel = new PopulationViewModel();
treeMap.DataSource = viewModel.PopulationDetails;
treeMap.PrimaryValuePath = "Population";
this.Content = treeMap;
public class PopulationDetails
{
public string Country { get; set; }
public string Continent { get; set; }
public int Population { get; set; }
}
public class PopulationViewModel
{
public PopulationViewModel()
{
this.PopulationDetails = new ObservableCollection<PopulationDetails>()
{
new PopulationDetails() { Continent ="North America", Country = "United States of America", Population = 339996564 },
new PopulationDetails() { Continent ="South America", Country = "Brazil", Population = 216422446 },
new PopulationDetails() { Continent ="North America", Country = "Mexico", Population = 128455567 },
new PopulationDetails() { Continent ="South America", Country = "Colombia", Population = 52085168 },
new PopulationDetails() { Continent ="South America", Country = "Argentina", Population = 45773884 },
new PopulationDetails() { Continent ="North America", Country = "Canada", Population = 38781292 },
new PopulationDetails() { Continent ="South America", Country = "Peru", Population = 34352719 },
new PopulationDetails() { Continent ="South America", Country = "Venezuela", Population = 28838499 },
new PopulationDetails() { Continent ="South America", Country = "Chile", Population = 19629590 },
new PopulationDetails() { Continent ="South America", Country = "Ecuador", Population = 18190484 },
new PopulationDetails() { Continent ="North America", Country = "Guatemala", Population = 18092026 },
new PopulationDetails() { Continent ="South America", Country = "Bolivia", Population = 12388571 },
new PopulationDetails() { Continent ="North America", Country = "Honduras", Population = 10593798 },
new PopulationDetails() { Continent ="North America", Country = "Nicaragua", Population = 7046311 },
new PopulationDetails() { Continent ="South America", Country = "Paraguay", Population = 6861524 },
new PopulationDetails() { Continent ="North America", Country = "El Salvador", Population = 6364943 },
new PopulationDetails() { Continent ="North America", Country = "Costa Rica", Population = 5212173 },
new PopulationDetails() { Continent ="South America", Country = "Uruguay", Population = 3423109 },
};
}
public ObservableCollection<PopulationDetails> PopulationDetails
{
get;
set;
}
}
DataSource
|
DataSource
|
Gets or sets a collection used to generate the item in the SfTreeMap. |
WeightValuePath
|
PrimaryValuePath
|
Gets or sets the name of the property in the data object that provides the primary value for each item in the SfTreeMap. |
ColorValuePath
|
RangeColorValuePath
|
Gets or sets the name of the property in the data object that provides the range color value for each item in the SfTreeMap control. |
HightlightColor
|
SelectedItemStroke
|
Gets or sets the stroke color for the selected item in the SfTreeMap. |
HightlightBorderWidth
|
SelectedItemStrokeWidth
|
Gets or sets the stroke width for the selected item in the SfTreeMap. |
LayoutType
|
LayoutType
|
Gets or sets the layout type used to arrange items using a specific layout algorithm. |
ItemTemplate
|
LeafItemTemplate
|
Gets or sets the data template to use for customizing the appearance of individual leaf items in the SfTreeMap. |
LeafItemSettings
|
LeafItemSettings
|
Gets or sets the settings for the leaf item, which is used to customize the stroke color, stroke width, text style, spacing between items, and text format option in the SfTreeMap. |
LeafItemColorMapping
|
LeafItemBrushSettings
|
Gets or sets the settings for the leaf item brush, which is used to customize the leaf items in the SfTreeMap. |
LegendSettings
|
LegendSettings
|
Gets or sets the settings for the legend, which is used to customize the icon size, text style, icon type, placement, show legend and legend size in the SfTreeMap. |
Levels
|
Levels
|
Gets or sets the collection of levels defining the hierarchical structure for grouped visualization of data in the SfTreeMap. |
SelectedItems
|
SelectedItems
|
Gets or sets the collection of tree map item representing the currently selected items in the SfTreeMap. |
SelectionMode
|
SelectionMode
|
Gets or sets the selection mode for the SfTreeMap. This property is used to customize the selection for tree map. |
ShowTooltip
|
ShowToolTip
|
Gets or sets a value indicating whether tool tips are displayed for items in the SfTreeMap. |
TooltipSettings
|
ToolTipSettings
|
Gets or sets the settings for the tool tips, which is used to customize the background, duration, stroke, and text style in the SfTreeMap. |
TooltipTemplate
|
ToolTipTemplate
|
Gets or sets the data template to use for customizing the appearance of tool tips for items in the SfTreeMap. |
Nil |
GroupItemBrushSettings
|
Gets or sets the settings for the group item brush, which is used to customize the group items in the SfTreeMap. |
TreeMapItemInfo
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
Nil |
Item
|
Gets or sets the item associated with the TreeMapItemInfo. |
Nil |
GroupLevel
|
Gets or sets the group level of the item. |
Nil |
Background
|
Gets the background brush for the item. |
Nil |
PrimaryValueText
|
Gets the primary value text of the item. |
LeafItemSettings
The following code example, explains how to configure the leaf item settings in .NET MAUI SfTreeMap control.
<treemap:SfTreeMap x:Name="treeMap"
DataSource="{Binding PopulationDetails}"
PrimaryValuePath="Population">
<treemap:SfTreeMap.BindingContext>
<local:PopulationViewModel />
</treemap:SfTreeMap.BindingContext>
<treemap:SfTreeMap.LeafItemSettings>
<treemap:TreeMapLeafItemSettings LabelPath="Country">
</treemap:TreeMapLeafItemSettings>
</treemap:SfTreeMap.LeafItemSettings>
<treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:TreeMapUniformBrushSettings Brush="Orange"/>
</treemap:SfTreeMap.LeafItemBrushSettings>
</treemap:SfTreeMap>
SfTreeMap treeMap = new SfTreeMap();
PopulationViewModel viewModel = new PopulationViewModel();
treeMap.DataSource = viewModel.PopulationDetails;
treeMap.PrimaryValuePath = "Population";
treeMap.LeafItemSettings = new TreeMapLeafItemSettings() { LabelPath = "Country" };
treeMap.LeafItemBrushSettings = new TreeMapUniformBrushSettings() { Brush = Brush.Orange };
this.Content = treeMap;
public class PopulationDetails
{
public string Country { get; set; }
public string Continent { get; set; }
public int Population { get; set; }
}
public class PopulationViewModel
{
public PopulationViewModel()
{
this.PopulationDetails = new ObservableCollection<PopulationDetails>()
{
new PopulationDetails() { Continent ="North America", Country = "United States of America", Population = 339996564 },
new PopulationDetails() { Continent ="South America", Country = "Brazil", Population = 216422446 },
new PopulationDetails() { Continent ="North America", Country = "Mexico", Population = 128455567 },
new PopulationDetails() { Continent ="South America", Country = "Colombia", Population = 52085168 },
new PopulationDetails() { Continent ="South America", Country = "Argentina", Population = 45773884 },
new PopulationDetails() { Continent ="North America", Country = "Canada", Population = 38781292 },
new PopulationDetails() { Continent ="South America", Country = "Peru", Population = 34352719 },
new PopulationDetails() { Continent ="South America", Country = "Venezuela", Population = 28838499 },
new PopulationDetails() { Continent ="South America", Country = "Chile", Population = 19629590 },
new PopulationDetails() { Continent ="South America", Country = "Ecuador", Population = 18190484 },
new PopulationDetails() { Continent ="North America", Country = "Guatemala", Population = 18092026 },
new PopulationDetails() { Continent ="South America", Country = "Bolivia", Population = 12388571 },
new PopulationDetails() { Continent ="North America", Country = "Honduras", Population = 10593798 },
new PopulationDetails() { Continent ="North America", Country = "Nicaragua", Population = 7046311 },
new PopulationDetails() { Continent ="South America", Country = "Paraguay", Population = 6861524 },
new PopulationDetails() { Continent ="North America", Country = "El Salvador", Population = 6364943 },
new PopulationDetails() { Continent ="North America", Country = "Costa Rica", Population = 5212173 },
new PopulationDetails() { Continent ="South America", Country = "Uruguay", Population = 3423109 },
};
}
public ObservableCollection<PopulationDetails> PopulationDetails
{
get;
set;
}
}
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
BorderColor
|
Stroke
|
Gets or sets the stroke color for the leaf items in the SfTreeMap. |
BorderWidth
|
StrokeWidth
|
Gets or sets the width of the stroke for the leaf items in the SfTreeMap. |
Gap
|
Spacing
|
Gets or sets the spacing between the leaf items in the SfTreeMap. |
LabelPath
|
LabelPath
|
Gets or sets the path of the label for the leaf items in the SfTreeMap. |
LabelStyle
|
TextStyle
|
Gets or sets the style of leaf item text, that is used to customize the text color, font, font size, font family and font attributes. |
OverflowMode
|
TextFormatOption
|
Gets or sets the text format option for the leaf items in the SfTreeMap. |
LegendSettings
The following code example, explains how to configure the legend settings in .NET MAUI SfTreeMap control.
<treemap:SfTreeMap x:Name="treeMap"
DataSource="{Binding PopulationDetails}"
PrimaryValuePath="Population"
RangeColorValuePath="Population">
<treemap:SfTreeMap.BindingContext>
<local:PopulationViewModel />
</treemap:SfTreeMap.BindingContext>
<treemap:SfTreeMap.LeafItemSettings>
<treemap:TreeMapLeafItemSettings LabelPath="Country">
</treemap:TreeMapLeafItemSettings>
</treemap:SfTreeMap.LeafItemSettings>
<treemap:SfTreeMap.LegendSettings>
<treemap:TreeMapLegendSettings ShowLegend="True">
</treemap:TreeMapLegendSettings>
</treemap:SfTreeMap.LegendSettings>
<treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:TreeMapRangeBrushSettings>
<treemap:TreeMapRangeBrushSettings.RangeBrushes>
<treemap:TreeMapRangeBrush LegendLabel="50M - 1B"
From="50000000"
To="1000000000"
Brush ="#F0A868" />
<treemap:TreeMapRangeBrush LegendLabel="10M - 50M"
From="10000000"
To="50000000"
Brush ="#F3BC8B" />
<treemap:TreeMapRangeBrush LegendLabel="0.1M - 10M"
From="100000"
To="10000000"
Brush= "#F8D7B9" />
</treemap:TreeMapRangeBrushSettings.RangeBrushes>
</treemap:TreeMapRangeBrushSettings>
</treemap:SfTreeMap.LeafItemBrushSettings>
</treemap:SfTreeMap>
SfTreeMap treeMap = new SfTreeMap();
PopulationViewModel viewModel = new PopulationViewModel();
treeMap.DataSource = viewModel.PopulationDetails;
treeMap.PrimaryValuePath = "Population";
treeMap.RangeColorValuePath = "Population";
treeMap.LeafItemSettings = new TreeMapLeafItemSettings() { LabelPath = "Country" };
treeMap.LegendSettings = new TreeMapLegendSettings() { ShowLegend = true };
treeMap.LeafItemBrushSettings = new TreeMapRangeBrushSettings()
{
RangeBrushes = new List<TreeMapRangeBrush>()
{
new TreeMapRangeBrush { LegendLabel = "50M - 1B", From = 50000000, To = 1000000000, Brush = new SolidColorBrush(Color.FromArgb("#F0A868")) },
new TreeMapRangeBrush { LegendLabel = "10M - 50M", From = 10000000, To = 50000000, Brush = new SolidColorBrush(Color.FromArgb("#F3BC8B")) },
new TreeMapRangeBrush { LegendLabel = "0.1M - 10M", From = 100000, To = 10000000, Brush = new SolidColorBrush(Color.FromArgb("#F8D7B9")) },
}
};
this.Content = treeMap;
public class PopulationDetails
{
public string Country { get; set; }
public string Continent { get; set; }
public int Population { get; set; }
}
public class PopulationViewModel
{
public PopulationViewModel()
{
this.PopulationDetails = new ObservableCollection<PopulationDetails>()
{
new PopulationDetails() { Continent ="North America", Country = "United States of America", Population = 339996564 },
new PopulationDetails() { Continent ="South America", Country = "Brazil", Population = 216422446 },
new PopulationDetails() { Continent ="North America", Country = "Mexico", Population = 128455567 },
new PopulationDetails() { Continent ="South America", Country = "Colombia", Population = 52085168 },
new PopulationDetails() { Continent ="South America", Country = "Argentina", Population = 45773884 },
new PopulationDetails() { Continent ="North America", Country = "Canada", Population = 38781292 },
new PopulationDetails() { Continent ="South America", Country = "Peru", Population = 34352719 },
new PopulationDetails() { Continent ="South America", Country = "Venezuela", Population = 28838499 },
new PopulationDetails() { Continent ="South America", Country = "Chile", Population = 19629590 },
new PopulationDetails() { Continent ="South America", Country = "Ecuador", Population = 18190484 },
new PopulationDetails() { Continent ="North America", Country = "Guatemala", Population = 18092026 },
new PopulationDetails() { Continent ="South America", Country = "Bolivia", Population = 12388571 },
new PopulationDetails() { Continent ="North America", Country = "Honduras", Population = 10593798 },
new PopulationDetails() { Continent ="North America", Country = "Nicaragua", Population = 7046311 },
new PopulationDetails() { Continent ="South America", Country = "Paraguay", Population = 6861524 },
new PopulationDetails() { Continent ="North America", Country = "El Salvador", Population = 6364943 },
new PopulationDetails() { Continent ="North America", Country = "Costa Rica", Population = 5212173 },
new PopulationDetails() { Continent ="South America", Country = "Uruguay", Population = 3423109 },
};
}
public ObservableCollection<PopulationDetails> PopulationDetails
{
get;
set;
}
}
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
ShowLegend
|
ShowLegend
|
Gets or sets a value indicating whether the legend is enabled in the SfTreeMap. |
IconSize
|
IconSize
|
Gets or sets the size of the legend icons in the SfTreeMap. |
LegendIcon
|
IconType
|
Gets or sets the type of icons to be used for the legend in the SfTreeMap. |
LegendPosition
|
Placement
|
Gets or sets the placement of the legend with in the SfTreeMap. |
Size
|
Size
|
Gets or sets the size of the legend layout in the SfTreeMap. |
LabelStyle
|
TextStyle
|
Gets or sets the style of legend item text, that is used to customize the text color, font, font size, font family and font attributes. |
The following code example, explains how to configure the uniform brush settings in .NET MAUI SfTreeMap control.
<treemap:SfTreeMap x:Name="treeMap"
DataSource="{Binding PopulationDetails}"
PrimaryValuePath="Population">
<treemap:SfTreeMap.BindingContext>
<local:PopulationViewModel />
</treemap:SfTreeMap.BindingContext>
<treemap:SfTreeMap.LeafItemSettings>
<treemap:TreeMapLeafItemSettings LabelPath="Country">
</treemap:TreeMapLeafItemSettings>
</treemap:SfTreeMap.LeafItemSettings>
<treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:TreeMapUniformBrushSettings Brush="Orange"/>
</treemap:SfTreeMap.LeafItemBrushSettings>
</treemap:SfTreeMap>
SfTreeMap treeMap = new SfTreeMap();
PopulationViewModel viewModel = new PopulationViewModel();
treeMap.DataSource = viewModel.PopulationDetails;
treeMap.PrimaryValuePath = "Population";
treeMap.LeafItemBrushSettings = new TreeMapUniformBrushSettings() { Brush = Brush.Orange };
treeMap.LeafItemSettings = new TreeMapLeafItemSettings() { LabelPath = "Country" };
this.Content = treeMap;
public class PopulationDetails
{
public string Country { get; set; }
public string Continent { get; set; }
public int Population { get; set; }
}
public class PopulationViewModel
{
public PopulationViewModel()
{
this.PopulationDetails = new ObservableCollection<PopulationDetails>()
{
new PopulationDetails() { Continent ="North America", Country = "United States of America", Population = 339996564 },
new PopulationDetails() { Continent ="South America", Country = "Brazil", Population = 216422446 },
new PopulationDetails() { Continent ="North America", Country = "Mexico", Population = 128455567 },
new PopulationDetails() { Continent ="South America", Country = "Colombia", Population = 52085168 },
new PopulationDetails() { Continent ="South America", Country = "Argentina", Population = 45773884 },
new PopulationDetails() { Continent ="North America", Country = "Canada", Population = 38781292 },
new PopulationDetails() { Continent ="South America", Country = "Peru", Population = 34352719 },
new PopulationDetails() { Continent ="South America", Country = "Venezuela", Population = 28838499 },
new PopulationDetails() { Continent ="South America", Country = "Chile", Population = 19629590 },
new PopulationDetails() { Continent ="South America", Country = "Ecuador", Population = 18190484 },
new PopulationDetails() { Continent ="North America", Country = "Guatemala", Population = 18092026 },
new PopulationDetails() { Continent ="South America", Country = "Bolivia", Population = 12388571 },
new PopulationDetails() { Continent ="North America", Country = "Honduras", Population = 10593798 },
new PopulationDetails() { Continent ="North America", Country = "Nicaragua", Population = 7046311 },
new PopulationDetails() { Continent ="South America", Country = "Paraguay", Population = 6861524 },
new PopulationDetails() { Continent ="North America", Country = "El Salvador", Population = 6364943 },
new PopulationDetails() { Continent ="North America", Country = "Costa Rica", Population = 5212173 },
new PopulationDetails() { Continent ="South America", Country = "Uruguay", Population = 3423109 },
};
}
public ObservableCollection<PopulationDetails> PopulationDetails
{
get;
set;
}
}
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
Color
|
Brush
|
Gets or sets the background brush for the tree map leaf items in the SfTreeMap. |
DesaturationBrushSettings
The following code example, explains how to configure the desaturation brush settings in .NET MAUI SfTreeMap control.
<treemap:SfTreeMap x:Name="treeMap"
DataSource="{Binding PopulationDetails}"
PrimaryValuePath="Population">
<treemap:SfTreeMap.BindingContext>
<local:PopulationViewModel />
</treemap:SfTreeMap.BindingContext>
<treemap:SfTreeMap.LeafItemSettings>
<treemap:TreeMapLeafItemSettings LabelPath="Country">
</treemap:TreeMapLeafItemSettings>
</treemap:SfTreeMap.LeafItemSettings>
<treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:TreeMapDesaturationBrushSettings Brush="BlueViolet" From="1" To="0.2"/>
</treemap:SfTreeMap.LeafItemBrushSettings>
</treemap:SfTreeMap>
SfTreeMap treeMap = new SfTreeMap();
PopulationViewModel viewModel = new PopulationViewModel();
treeMap.DataSource = viewModel.PopulationDetails;
treeMap.PrimaryValuePath = "Population";
treeMap.LeafItemSettings = new TreeMapLeafItemSettings() { LabelPath = "Country" };
treeMap.LeafItemBrushSettings = new TreeMapDesaturationBrushSettings() { Brush = Brush.BlueViolet, From = 1, To = 0.2 };
this.Content = treeMap;
public class PopulationDetails
{
public string Country { get; set; }
public string Continent { get; set; }
public int Population { get; set; }
}
public class PopulationViewModel
{
public PopulationViewModel()
{
this.PopulationDetails = new ObservableCollection<PopulationDetails>()
{
new PopulationDetails() { Continent ="North America", Country = "United States of America", Population = 339996564 },
new PopulationDetails() { Continent ="South America", Country = "Brazil", Population = 216422446 },
new PopulationDetails() { Continent ="North America", Country = "Mexico", Population = 128455567 },
new PopulationDetails() { Continent ="South America", Country = "Colombia", Population = 52085168 },
new PopulationDetails() { Continent ="South America", Country = "Argentina", Population = 45773884 },
new PopulationDetails() { Continent ="North America", Country = "Canada", Population = 38781292 },
new PopulationDetails() { Continent ="South America", Country = "Peru", Population = 34352719 },
new PopulationDetails() { Continent ="South America", Country = "Venezuela", Population = 28838499 },
new PopulationDetails() { Continent ="South America", Country = "Chile", Population = 19629590 },
new PopulationDetails() { Continent ="South America", Country = "Ecuador", Population = 18190484 },
new PopulationDetails() { Continent ="North America", Country = "Guatemala", Population = 18092026 },
new PopulationDetails() { Continent ="South America", Country = "Bolivia", Population = 12388571 },
new PopulationDetails() { Continent ="North America", Country = "Honduras", Population = 10593798 },
new PopulationDetails() { Continent ="North America", Country = "Nicaragua", Population = 7046311 },
new PopulationDetails() { Continent ="South America", Country = "Paraguay", Population = 6861524 },
new PopulationDetails() { Continent ="North America", Country = "El Salvador", Population = 6364943 },
new PopulationDetails() { Continent ="North America", Country = "Costa Rica", Population = 5212173 },
new PopulationDetails() { Continent ="South America", Country = "Uruguay", Population = 3423109 },
};
}
public ObservableCollection<PopulationDetails> PopulationDetails
{
get;
set;
}
}
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
Color
|
Brush
|
Gets or sets the background brush for the desaturation in the SfTreeMap. |
From
|
From
|
Gets or sets the starting value for the desaturation range in the SfTreeMap. |
To
|
To
|
Gets or sets the ending value for the desaturation range in the SfTreeMap. |
PaletteBrushSettings
The following code example, explains how to configure the palette brush settings in .NET MAUI SfTreeMap control.
<treemap:SfTreeMap x:Name="treeMap"
DataSource="{Binding PopulationDetails}"
PrimaryValuePath="Population"
RangeColorValuePath="Population">
<treemap:SfTreeMap.BindingContext>
<local:PopulationViewModel />
</treemap:SfTreeMap.BindingContext>
<treemap:SfTreeMap.LeafItemSettings>
<treemap:TreeMapLeafItemSettings LabelPath="Country">
</treemap:TreeMapLeafItemSettings>
</treemap:SfTreeMap.LeafItemSettings>
<treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:TreeMapPaletteBrushSettings>
<treemap:TreeMapPaletteBrushSettings.Brushes>
<SolidColorBrush>#116DF9</SolidColorBrush>
<SolidColorBrush>#9215F3</SolidColorBrush>
<SolidColorBrush>#F4890B</SolidColorBrush>
<SolidColorBrush>#D21243</SolidColorBrush>
<SolidColorBrush>#E2227E</SolidColorBrush>
<SolidColorBrush>#9215F3</SolidColorBrush>
</treemap:TreeMapPaletteBrushSettings.Brushes>
</treemap:TreeMapPaletteBrushSettings>
</treemap:SfTreeMap.LeafItemBrushSettings>
</treemap:SfTreeMap>
SfTreeMap treeMap = new SfTreeMap();
PopulationViewModel viewModel = new PopulationViewModel();
treeMap.DataSource = viewModel.PopulationDetails;
treeMap.PrimaryValuePath = "Population";
treeMap.RangeColorValuePath = "Population";
treeMap.LeafItemSettings = new TreeMapLeafItemSettings() { LabelPath = "Country" };
treeMap.LeafItemBrushSettings = new TreeMapPaletteBrushSettings()
{
Brushes = new List<Brush>()
{
new SolidColorBrush(Color.FromArgb("#116DF9")),
new SolidColorBrush(Color.FromArgb("#9215F3")),
new SolidColorBrush(Color.FromArgb("#F4890B")),
new SolidColorBrush(Color.FromArgb("#D21243")),
new SolidColorBrush(Color.FromArgb("#E2227E")),
new SolidColorBrush(Color.FromArgb("#9215F3")),
}
};
this.Content = treeMap;
public class PopulationDetails
{
public string Country { get; set; }
public string Continent { get; set; }
public int Population { get; set; }
}
public class PopulationViewModel
{
public PopulationViewModel()
{
this.PopulationDetails = new ObservableCollection<PopulationDetails>()
{
new PopulationDetails() { Continent ="North America", Country = "United States of America", Population = 339996564 },
new PopulationDetails() { Continent ="South America", Country = "Brazil", Population = 216422446 },
new PopulationDetails() { Continent ="North America", Country = "Mexico", Population = 128455567 },
new PopulationDetails() { Continent ="South America", Country = "Colombia", Population = 52085168 },
new PopulationDetails() { Continent ="South America", Country = "Argentina", Population = 45773884 },
new PopulationDetails() { Continent ="North America", Country = "Canada", Population = 38781292 },
new PopulationDetails() { Continent ="South America", Country = "Peru", Population = 34352719 },
new PopulationDetails() { Continent ="South America", Country = "Venezuela", Population = 28838499 },
new PopulationDetails() { Continent ="South America", Country = "Chile", Population = 19629590 },
new PopulationDetails() { Continent ="South America", Country = "Ecuador", Population = 18190484 },
new PopulationDetails() { Continent ="North America", Country = "Guatemala", Population = 18092026 },
new PopulationDetails() { Continent ="South America", Country = "Bolivia", Population = 12388571 },
new PopulationDetails() { Continent ="North America", Country = "Honduras", Population = 10593798 },
new PopulationDetails() { Continent ="North America", Country = "Nicaragua", Population = 7046311 },
new PopulationDetails() { Continent ="South America", Country = "Paraguay", Population = 6861524 },
new PopulationDetails() { Continent ="North America", Country = "El Salvador", Population = 6364943 },
new PopulationDetails() { Continent ="North America", Country = "Costa Rica", Population = 5212173 },
new PopulationDetails() { Continent ="South America", Country = "Uruguay", Population = 3423109 },
};
}
public ObservableCollection<PopulationDetails> PopulationDetails
{
get;
set;
}
}
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
Colors
|
Brushes
|
Gets or sets the list of brushes used for the palette in the SfTreeMap. |
RangeBrushSettings
To categorize leaf items in a TreeMap according to different ranges of background color values, use TreeMapRangeBrushSettings. Define the upper and lower limits of each range using the To and From properties of TreeMapRangeBrush.
RangeBrush
The following code example explains how to configure the range brush in .NET MAUI SfTreeMap control.
<treemap:SfTreeMap x:Name="treeMap"
DataSource="{Binding PopulationDetails}"
PrimaryValuePath="Population"
RangeColorValuePath="Population">
<treemap:SfTreeMap.BindingContext>
<local:PopulationViewModel />
</treemap:SfTreeMap.BindingContext>
<treemap:SfTreeMap.LeafItemSettings>
<treemap:TreeMapLeafItemSettings LabelPath="Country">
</treemap:TreeMapLeafItemSettings>
</treemap:SfTreeMap.LeafItemSettings>
<treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:TreeMapRangeBrushSettings>
<treemap:TreeMapRangeBrushSettings.RangeBrushes>
<treemap:TreeMapRangeBrush LegendLabel="50M - 1B"
From="50000000"
To="1000000000"
Brush ="#F0A868" />
<treemap:TreeMapRangeBrush LegendLabel="10M - 50M"
From="10000000"
To="50000000"
Brush ="#F3BC8B" />
<treemap:TreeMapRangeBrush LegendLabel="0.1M - 10M"
From="100000"
To="10000000"
Brush= "#F8D7B9" />
</treemap:TreeMapRangeBrushSettings.RangeBrushes>
</treemap:TreeMapRangeBrushSettings>
</treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:SfTreeMap.LegendSettings>
<treemap:TreeMapLegendSettings ShowLegend="True">
</treemap:TreeMapLegendSettings>
</treemap:SfTreeMap.LegendSettings>
</treemap:SfTreeMap>
SfTreeMap treeMap = new SfTreeMap();
PopulationViewModel viewModel = new PopulationViewModel();
treeMap.DataSource = viewModel.PopulationDetails;
treeMap.PrimaryValuePath = "Population";
treeMap.RangeColorValuePath = "Population";
treeMap.LeafItemSettings = new TreeMapLeafItemSettings() { LabelPath = "Country" };
treeMap.LeafItemBrushSettings = new TreeMapRangeBrushSettings()
{
RangeBrushes = new List<TreeMapRangeBrush>()
{
new TreeMapRangeBrush() { LegendLabel="50M - 1B", From=50000000, To=1000000000, Brush = new SolidColorBrush(Color.FromArgb("#F0A868")) },
new TreeMapRangeBrush() { LegendLabel="10M - 50M", From=10000000, To=50000000, Brush = new SolidColorBrush(Color.FromArgb("#F3BC8B")) },
new TreeMapRangeBrush() { LegendLabel="0.1M - 10M", From=100000, To=10000000, Brush = new SolidColorBrush(Color.FromArgb("#F8D7B9")) },
}
};
treeMap.LegendSettings = new TreeMapLegendSettings() { ShowLegend = true };
this.Content = treeMap;
public class PopulationDetails
{
public string Country { get; set; }
public string Continent { get; set; }
public int Population { get; set; }
}
public class PopulationViewModel
{
public PopulationViewModel()
{
this.PopulationDetails = new ObservableCollection<PopulationDetails>()
{
new PopulationDetails() { Continent ="North America", Country = "United States of America", Population = 339996564 },
new PopulationDetails() { Continent ="South America", Country = "Brazil", Population = 216422446 },
new PopulationDetails() { Continent ="North America", Country = "Mexico", Population = 128455567 },
new PopulationDetails() { Continent ="South America", Country = "Colombia", Population = 52085168 },
new PopulationDetails() { Continent ="South America", Country = "Argentina", Population = 45773884 },
new PopulationDetails() { Continent ="North America", Country = "Canada", Population = 38781292 },
new PopulationDetails() { Continent ="South America", Country = "Peru", Population = 34352719 },
new PopulationDetails() { Continent ="South America", Country = "Venezuela", Population = 28838499 },
new PopulationDetails() { Continent ="South America", Country = "Chile", Population = 19629590 },
new PopulationDetails() { Continent ="South America", Country = "Ecuador", Population = 18190484 },
new PopulationDetails() { Continent ="North America", Country = "Guatemala", Population = 18092026 },
new PopulationDetails() { Continent ="South America", Country = "Bolivia", Population = 12388571 },
new PopulationDetails() { Continent ="North America", Country = "Honduras", Population = 10593798 },
new PopulationDetails() { Continent ="North America", Country = "Nicaragua", Population = 7046311 },
new PopulationDetails() { Continent ="South America", Country = "Paraguay", Population = 6861524 },
new PopulationDetails() { Continent ="North America", Country = "El Salvador", Population = 6364943 },
new PopulationDetails() { Continent ="North America", Country = "Costa Rica", Population = 5212173 },
new PopulationDetails() { Continent ="South America", Country = "Uruguay", Population = 3423109 },
};
}
public ObservableCollection<PopulationDetails> PopulationDetails
{
get;
set;
}
}
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
LegendLabel
|
LegendLabel
|
Gets or sets the text for the legend item associated with the range in the SfTreeMap. |
Color
|
Brush
|
Gets or sets the background brush for the range in the SfTreeMap. |
From
|
From
|
Gets or sets the starting value of the range for the background brush in the SfTreeMap. |
To
|
To
|
Gets or sets the ending value of the range for the background brush in the SfTreeMap. |
The following code example, explains how to configure the tooltip setting in .NET MAUI SfTreeMap control.
<treemap:SfTreeMap x:Name="treeMap"
DataSource="{Binding PopulationDetails}"
PrimaryValuePath="Population"
ShowToolTip="True">
<treemap:SfTreeMap.BindingContext>
<local:PopulationViewModel />
</treemap:SfTreeMap.BindingContext>
<treemap:SfTreeMap.LeafItemSettings>
<treemap:TreeMapLeafItemSettings LabelPath="Country">
</treemap:TreeMapLeafItemSettings>
</treemap:SfTreeMap.LeafItemSettings>
<treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:TreeMapUniformBrushSettings Brush="Orange"/>
</treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:SfTreeMap.ToolTipSettings >
<treemap:TreeMapToolTipSettings Background = "Red" />
</treemap:SfTreeMap.ToolTipSettings >
</treemap:SfTreeMap>
SfTreeMap treeMap = new SfTreeMap();
PopulationViewModel viewModel = new PopulationViewModel();
treeMap.DataSource = viewModel.PopulationDetails;
treeMap.PrimaryValuePath = "Population";
treeMap.ShowToolTip = true;
treeMap.LeafItemBrushSettings = new TreeMapUniformBrushSettings() { Brush = Brush.Orange };
treeMap.LeafItemSettings = new TreeMapLeafItemSettings() { LabelPath = "Country" };
treeMap.ToolTipSettings = new TreeMapToolTipSettings() { Background = Brush.Red };
this.Content = treeMap;
public class PopulationDetails
{
public string Country { get; set; }
public string Continent { get; set; }
public int Population { get; set; }
}
public class PopulationViewModel
{
public PopulationViewModel()
{
this.PopulationDetails = new ObservableCollection<PopulationDetails>()
{
new PopulationDetails() { Continent ="North America", Country = "United States of America", Population = 339996564 },
new PopulationDetails() { Continent ="South America", Country = "Brazil", Population = 216422446 },
new PopulationDetails() { Continent ="North America", Country = "Mexico", Population = 128455567 },
new PopulationDetails() { Continent ="South America", Country = "Colombia", Population = 52085168 },
new PopulationDetails() { Continent ="South America", Country = "Argentina", Population = 45773884 },
new PopulationDetails() { Continent ="North America", Country = "Canada", Population = 38781292 },
new PopulationDetails() { Continent ="South America", Country = "Peru", Population = 34352719 },
new PopulationDetails() { Continent ="South America", Country = "Venezuela", Population = 28838499 },
new PopulationDetails() { Continent ="South America", Country = "Chile", Population = 19629590 },
new PopulationDetails() { Continent ="South America", Country = "Ecuador", Population = 18190484 },
new PopulationDetails() { Continent ="North America", Country = "Guatemala", Population = 18092026 },
new PopulationDetails() { Continent ="South America", Country = "Bolivia", Population = 12388571 },
new PopulationDetails() { Continent ="North America", Country = "Honduras", Population = 10593798 },
new PopulationDetails() { Continent ="North America", Country = "Nicaragua", Population = 7046311 },
new PopulationDetails() { Continent ="South America", Country = "Paraguay", Population = 6861524 },
new PopulationDetails() { Continent ="North America", Country = "El Salvador", Population = 6364943 },
new PopulationDetails() { Continent ="North America", Country = "Costa Rica", Population = 5212173 },
new PopulationDetails() { Continent ="South America", Country = "Uruguay", Population = 3423109 },
};
}
public ObservableCollection<PopulationDetails> PopulationDetails
{
get;
set;
}
}
Levels
The following code example, explains how to configure the tree map level in .NET MAUI SfTreeMap control.
<treemap:SfTreeMap x:Name="treeMap"
DataSource="{Binding PopulationDetails}"
PrimaryValuePath="Population">
<treemap:SfTreeMap.BindingContext>
<local:PopulationViewModel />
</treemap:SfTreeMap.BindingContext>
<treemap:SfTreeMap.LeafItemSettings>
<treemap:TreeMapLeafItemSettings LabelPath="Country">
</treemap:TreeMapLeafItemSettings>
</treemap:SfTreeMap.LeafItemSettings>
<treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:TreeMapUniformBrushSettings Brush="Orange"/>
</treemap:SfTreeMap.LeafItemBrushSettings>
<treemap:SfTreeMap.Levels>
<treemap:TreeMapLevel GroupPath="Continent"/>
</treemap:SfTreeMap.Levels>
</treemap:SfTreeMap>
SfTreeMap treeMap = new SfTreeMap();
PopulationViewModel viewModel = new PopulationViewModel();
treeMap.DataSource = viewModel.PopulationDetails;
treeMap.PrimaryValuePath = "Population";
treeMap.LeafItemBrushSettings = new TreeMapUniformBrushSettings() { Brush = Brush.Orange };
treeMap.LeafItemSettings = new TreeMapLeafItemSettings() { LabelPath = "Country" };
treeMap.Levels.Add(new TreeMapLevel() { GroupPath = "Continent"});
this.Content = treeMap;
public class PopulationDetails
{
public string Country { get; set; }
public string Continent { get; set; }
public int Population { get; set; }
}
public class PopulationViewModel
{
public PopulationViewModel()
{
this.PopulationDetails = new ObservableCollection<PopulationDetails>()
{
new PopulationDetails() { Continent ="North America", Country = "United States of America", Population = 339996564 },
new PopulationDetails() { Continent ="South America", Country = "Brazil", Population = 216422446 },
new PopulationDetails() { Continent ="North America", Country = "Mexico", Population = 128455567 },
new PopulationDetails() { Continent ="South America", Country = "Colombia", Population = 52085168 },
new PopulationDetails() { Continent ="South America", Country = "Argentina", Population = 45773884 },
new PopulationDetails() { Continent ="North America", Country = "Canada", Population = 38781292 },
new PopulationDetails() { Continent ="South America", Country = "Peru", Population = 34352719 },
new PopulationDetails() { Continent ="South America", Country = "Venezuela", Population = 28838499 },
new PopulationDetails() { Continent ="South America", Country = "Chile", Population = 19629590 },
new PopulationDetails() { Continent ="South America", Country = "Ecuador", Population = 18190484 },
new PopulationDetails() { Continent ="North America", Country = "Guatemala", Population = 18092026 },
new PopulationDetails() { Continent ="South America", Country = "Bolivia", Population = 12388571 },
new PopulationDetails() { Continent ="North America", Country = "Honduras", Population = 10593798 },
new PopulationDetails() { Continent ="North America", Country = "Nicaragua", Population = 7046311 },
new PopulationDetails() { Continent ="South America", Country = "Paraguay", Population = 6861524 },
new PopulationDetails() { Continent ="North America", Country = "El Salvador", Population = 6364943 },
new PopulationDetails() { Continent ="North America", Country = "Costa Rica", Population = 5212173 },
new PopulationDetails() { Continent ="South America", Country = "Uruguay", Population = 3423109 },
};
}
public ObservableCollection<PopulationDetails> PopulationDetails
{
get;
set;
}
}
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
LabelPath
|
GroupPath
|
Gets or sets the property path used for grouping tree map items in the SfTreeMap. |
GroupBackground
|
Background
|
Gets or sets the background brush for the tree map header items in the SfTreeMap. |
GroupBorderColor
|
Stroke
|
Gets or sets the stroke color for the tree map header items in the SfTreeMap. |
GroupBorderThickness
|
StrokeWidth
|
Gets or sets the width of the stroke for the tree map header items in the SfTreeMap. |
GroupGap
|
Spacing
|
Gets or sets the spacing between the tree map header items in the SfTreeMap. |
HeaderStyle
|
TextStyle
|
Gets or sets the style of header item text, that used to customize the text color, font, font size, font family and font attributes. |
HeaderHeight
|
HeaderHeight
|
Gets or sets the height of the header for each level in the SfTreeMap. |
TextStyle
The TextColor, FontSize, FontFamily, and FontAttributes properties of the SfTreeMap is grouped to TreeMapTextStyle.
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
Color
|
TextColor
|
Gets or sets the text color for the SfTreeMap. |
FontSize
|
FontSize
|
Gets or sets the double value that represents the font size of the SfTreeMap. |
FontFamily
|
FontFamily
|
Gets or sets the string, that represents font family of the SfTreeMap. |
FontAttributes
|
FontAttributes
|
Gets or sets the FontAttributes of the SfTreeMap. |
Enum
Event
Xamarin SfTreeMap control |
.NET MAUI SfTreeMap control |
Description |
ItemSelected
|
SelectionChanged
|
Occurs when the selection within the tree map item is changed. |