Skip to main content

CrosshairAxisLabelElement Class

Defines the appearance of the crosshair value and crosshair argument labels when custom drawing a crosshair cursor using the ChartControl.CustomDrawCrosshair event.

Namespace: DevExpress.Xpf.Charts

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

NuGet Package: DevExpress.Wpf.Charts


public class CrosshairAxisLabelElement :

The following members return CrosshairAxisLabelElement objects:


To get access to the appearance properties of the CrosshairAxisLabelElement object, use the DevExpress.Xpf.Charts.CrosshairElement.AxisLabelElement property when dealing with crosshair value labels and the CustomDrawCrosshairEventArgs.CrosshairAxisLabelElements property for the crosshair argument labels if the CrosshairOptions.SnapMode property is set to NearestArgument.

When the CrosshairOptions.SnapMode property is set to NearestValue, these properties will affect other crosshair axis labels. For instance, the CustomDrawCrosshairEventArgs.CrosshairAxisLabelElements property will change the appearance of the crosshair value labels in this case.

For more information on crosshair cursors, see Crosshair Cursor.


This example shows how to use the ChartControl.CustomDrawCrosshair event to customize the crosshair cursor. For example, you can use this event to paint crosshair label items depending on the highlighted point value. In this example, the ChartControl.CustomDrawCrosshair event is invoked when you click the Custom Draw Crosshair Cursor button on the form.

Enable the following properties before the crosshair is customized to display crosshair axis lines and labels:

View Example

<Window x:Class="CrosshairCustomDraw.MainWindow"
        Title="MainWindow" Height="414" Width="525">
            <dxc:ChartControl Name="chartControl1" Height="340" 
                    <dxc:CrosshairOptions ShowArgumentLabels="True" 
                                <dxc:CrosshairAxisLabelOptions Pattern="{}{V:f1}"/>
                    <dxc:LineSeries2D DisplayName="Series1">
                        <dxc:SeriesPoint Argument="1" Value="50"/>
                        <dxc:SeriesPoint Argument="2" Value="44"/>
                        <dxc:SeriesPoint Argument="3" Value="55"/>
                        <dxc:SeriesPoint Argument="4" Value="77"/>
                    <dxc:LineSeries2D DisplayName="Series2">
                        <dxc:SeriesPoint Argument="1" Value="22"/>
                        <dxc:SeriesPoint Argument="2" Value="11"/>
                        <dxc:SeriesPoint Argument="3" Value="9"/>
                        <dxc:SeriesPoint Argument="4" Value="8"/>
            <Button Height="35" Content="Custom Draw Crosshair Cursor" Click="Button_Click"></Button>
using DevExpress.Xpf.Charts;
using System.Windows;
using System.Windows.Media;

namespace CrosshairCustomDraw {
    public partial class MainWindow : Window {
        bool handleCustomDraw;
        public MainWindow() {
        private void Button_Click(object sender, RoutedEventArgs e) {
            handleCustomDraw = true;
            chartControl1.CustomDrawCrosshair += chartControl1_CustomDrawCrosshair;
        private void chartControl1_CustomDrawCrosshair(object sender, CustomDrawCrosshairEventArgs e) {

            if (!handleCustomDraw) return;

            // Specify the crosshair argument line color, dash style and thickness.
            e.CrosshairLineElement.Brush = Brushes.Aqua;
            e.CrosshairLineElement.LineStyle.DashStyle = DashStyles.DashDot;
            e.CrosshairLineElement.LineStyle.Thickness = 3;

            // Specify  the back color for crosshair argument label. 
            foreach (CrosshairAxisLabelElement axisLabelElement in e.CrosshairAxisLabelElements)
                axisLabelElement.Background = Brushes.Blue;

            foreach (CrosshairElementGroup group in e.CrosshairElementGroups) {
                CrosshairElement element = group.CrosshairElements[0];

                // Specify the color, dash style and thickness for the crosshair value lines. 
                element.LineElement.Brush = Brushes.DarkViolet;
                element.LineElement.LineStyle.DashStyle = DashStyles.Dash;
                element.LineElement.LineStyle.Thickness = 2;

                // Specify the  font size and background for the crosshair value labels.
                element.AxisLabelElement.FontSize = 14;
                element.AxisLabelElement.Background = Brushes.Red;

                // Specify the foreground and  font size for the crosshair  cursor label that shows series. 
                if (element.SeriesPoint.Value > 50) {
                    element.LabelElement.Foreground = Brushes.Green;
                    element.LabelElement.FontSize = 14;

            foreach (CrosshairElementGroup group in e.CrosshairElementGroups) {
                CrosshairGroupHeaderElement groupHeaderElement = group.HeaderElement;

                // Specify the text, text color and font for the crosshair group header element. 
                groupHeaderElement.Text = "Custom draw";
                groupHeaderElement.Foreground = Brushes.Red;
                groupHeaderElement.FontSize = 15;


See Also