Axis2D.CrosshairLabelTemplate Property
Specifies the template that defines the presentation of the Crosshair Cursor’s axis labels for the X-axis (Y-axis). This is a dependency property.
Namespace: DevExpress.Xpf.Charts
Assembly: DevExpress.Xpf.Charts.v19.1.dll
Declaration
Property Value
Type | Description |
---|---|
DataTemplate | The template defining the presentation of the Crosshair Cursor’s axis labels. |
Remarks
This template uses the CrosshairAxisLabelPresentationData class’ object as the data context.
Example
This example shows how to customize the visual representation of axis crosshair labels via their template.
To accomplish this, it is necessary to create a DataTemplate object that specifies the appearance of axis crosshair labels, and assign it to the Axis2D.CrosshairLabelTemplate
property.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-customize-the-appearance-of-crosshair-axis-labels-e4074.
<Window x:Class="CrosshairLabelTemplateForAxisLabels.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
Title="MainWindow" Height="350" Width="525" >
<Grid>
<dxc:ChartControl>
<!--#region CrosshairOptions-->
<dxc:ChartControl.CrosshairOptions>
<dxc:CrosshairOptions ShowArgumentLabels="True" ShowArgumentLine="True"
ShowValueLabels="True" ShowValueLine="True" ShowCrosshairLabels="False"/>
</dxc:ChartControl.CrosshairOptions>
<!--#endregion CrosshairOptions-->
<dxc:XYDiagram2D>
<dxc:XYDiagram2D.AxisX>
<dxc:AxisX2D>
<dxc:AxisX2D.CrosshairLabelTemplate>
<DataTemplate>
<Grid>
<Border BorderThickness="0.9">
<Border.Background>
<SolidColorBrush Color="Lavender" />
</Border.Background>
<Label BorderThickness="0.1" FontStyle="Oblique"
Content="{Binding Path=Text}" Padding="12,1,5,1.5"
Foreground="Green" FontSize="14"/>
</Border>
</Grid>
</DataTemplate>
</dxc:AxisX2D.CrosshairLabelTemplate>
</dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>
<dxc:BarSideBySideSeries2D ColorEach="True">
<dxc:BarSideBySideSeries2D.Points>
<dxc:SeriesPoint Argument="A" Value="2" />
<dxc:SeriesPoint Argument="B" Value="3" />
<dxc:SeriesPoint Argument="C" Value="5" />
<dxc:SeriesPoint Argument="D" Value="7" />
</dxc:BarSideBySideSeries2D.Points>
</dxc:BarSideBySideSeries2D>
</dxc:XYDiagram2D>
</dxc:ChartControl>
</Grid>
</Window>
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CrosshairLabelTemplate property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.