Axis2D.CustomLabelItemTemplateSelector Property

Gets or sets the custom logic for selecting a data template that converts a model object to a custom label.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v20.1.dll


public DataTemplateSelector CustomLabelItemTemplateSelector { get; set; }
Public Property CustomLabelItemTemplateSelector As DataTemplateSelector

Property Value

Type Description

A DataTemplateSelector descendant that applies a template based on custom logic.


To implement custom logic to choose a template, create a DataTemplateSelector descendant and override the SelectTemplate method. This method returns a data template for the specified axis label item.


The following code generates custom axis labels. The label template is selected based on the SelectTemplate method's returned value.


            <dxc:AxisY2D CustomLabelItemsSource="{Binding CustomLabels}">
                                <dxc:CustomAxisLabel Value="{Binding AxisValue}">
                                        <TextBlock FontSize="20" 
                                                   Text="{Binding SourceObject.LabelContent}">
                                <dxc:CustomAxisLabel Value="{Binding AxisValue}">
                                        <TextBlock FontSize="15" 
                                                   Text="{Binding Value}">
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

// ChartViewModel
public class ChartViewModel
    public ObservableCollection<LabelItem> CustomLabels { get; set; }
    public ChartViewModel()
        CustomLabels = new ObservableCollection<LabelItem>();
        CustomLabels.Add(new LabelItem() { AxisValue = 5, LabelContent = "5++" });
        CustomLabels.Add(new LabelItem() { AxisValue = 10, LabelContent = "10++"});
        CustomLabels.Add(new LabelItem() { AxisValue = 15, LabelContent = "15**" });
// CustomLabelSelector
class CustomLabelSelector : DataTemplateSelector {
    public DataTemplate BelowLevel { get; set; }
    public DataTemplate AboveLevel { get; set; }

    public override DataTemplate SelectTemplate(object item, DependencyObject container) {
        LabelItem axisLabel = item as LabelItem;
        if (axisLabel == null)
            return null;
        return axisLabel.AxisValue >= 10 ? AboveLevel : BelowLevel;
// LabelItem
public class LabelItem
    public double AxisValue { get; set; }
    public string LabelContent { get; set; }
See Also