Back to Devexpress

CrosshairIndicatorLegendElement Class

wpf-devexpress-dot-xpf-dot-charts-5fe8287d.md

latest4.3 KB
Original Source

CrosshairIndicatorLegendElement Class

The Crosshair Cursor‘s element that shows information about the indicator in a legend.

Namespace : DevExpress.Xpf.Charts

Assembly : DevExpress.Xpf.Charts.v25.2.dll

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public class CrosshairIndicatorLegendElement :
    CrosshairLegendElementBase
vb
Public Class CrosshairIndicatorLegendElement
    Inherits CrosshairLegendElementBase

Example

This example shows how to modify the Crosshair Cursor indicator elements’ appearance using the CustomDrawCrosshair event.

In this sample, crosshair content is displayed in a legend. For this, set the ContentShowMode property to Legend. Note that you can specify the crosshair’s content show mode for a specified indicator using the CrosshairContentShowMode property.

Use the IndicatorLegendElements property to obtain a collection of indicator elements.

The following properties allow you to modify indicator element appearance:

PropertyDescription
IndicatorPointReturns information about an indicator point under a crosshair.
CrosshairLegendElementBase.LineElementReturns the crosshair line settings.
CrosshairLegendElementBase.AxisLabelElementReturns the crosshair axis label settings.
xaml
<dxc:ChartControl x:Name="chartControl" 
                  CustomDrawCrosshair="chartControl_CustomDrawCrosshair">
    <dxc:ChartControl.CrosshairOptions>
        <dxc:CrosshairOptions ShowOnlyInFocusedPane="False" 
                              ShowValueLine="True"
                              ShowValueLabels="True"
                              ContentShowMode="Legend"/>
    </dxc:ChartControl.CrosshairOptions>
    <!--...-->
</dxc:ChartControl>
csharp
private void chartControl_CustomDrawCrosshair(object sender, CustomDrawCrosshairEventArgs e) {
    Brush brush = new SolidColorBrush(Colors.Green);
    foreach(CrosshairIndicatorLegendElement indicatorLegendElement in e.IndicatorLegendElements) {
        if(indicatorLegendElement.IndicatorPoint.GetNumericValue(IndicatorValueLevel.Value) > 0) {
            indicatorLegendElement.LineElement.Brush = brush;            
            indicatorLegendElement.LineElement.LineStyle.DashStyle = new DashStyle(new double[] {5, 2}, 2);
            indicatorLegendElement.AxisLabelElement.Background = brush;
        }
    }
}
vb
Private Sub chartControl_CustomDrawCrosshair(ByVal sender As Object, ByVal e As CustomDrawCrosshairEventArgs)
    Dim brush As Brush = New SolidColorBrush(Colors.Green)

    For Each indicatorLegendElement As CrosshairIndicatorLegendElement In e.IndicatorLegendElements

        If indicatorLegendElement.IndicatorPoint.GetNumericValue(IndicatorValueLevel.Value) > 0 Then
            indicatorLegendElement.LineElement.Brush = brush
            indicatorLegendElement.LineElement.LineStyle.DashStyle = New DashStyle(New Double() {5, 2}, 2)
            indicatorLegendElement.AxisLabelElement.Background = brush
        End If
    Next
End Sub

Inheritance

Object CrosshairLabelElementBase CrosshairLegendElementBase CrosshairIndicatorLegendElement

See Also

CrosshairIndicatorLegendElement Members

DevExpress.Xpf.Charts Namespace