How To Restrict The Tooltip On A WPF Chart

Updated on Jun 01, 2025
chart restrict-tooltip show-datamarker-tooltip wpf-chart

WPF Chart Tooltip displays data information over a chart segment by setting the ShowTooltip property to true. This section explains how to restrict the tooltip hovering over a segment and how to show the tooltip hovering over a marker of the segment.

To display the tooltip over a marker in the segment, you can use the ShowMarker property of the chart segment and set it to true. This will display markers on the chart segment, and the tooltip will appear over the marker when the pointer has hovered over it.

This is the actual behavior of tooltip rendering over a segment with a pointer position. You can set the Position of the tooltip as Pointer, it will display the information on every hover over the segment.

MainWindow-2023-02-13-10-26-12

The tooltip rendering on the segment has been restricted according to the code snippet below:

[C#]

public class LineSeriesExt : LineSeries
{
    protected override void OnMouseMove(MouseEventArgs e)
    {
        //To restrict tooltip when hover on the line segment
        if (e.OriginalSource is Line)
            return;
        base.OnMouseMove(e);
    }
}

[XAML]

<chart:SfChart>
    <chart:SfChart.PrimaryAxis>
        <chart:CategoryAxis PlotOffset="20" ShowGridLines="False" />
    </chart:SfChart.PrimaryAxis>

    <chart:SfChart.SecondaryAxis>
        <chart:NumericalAxis Maximum="120" Minimum="0" ShowGridLines="False" PlotOffset="12"/>
    </chart:SfChart.SecondaryAxis>

    <chart:SfChart.Behaviors>
        <chart:ChartTooltipBehavior Position="Pointer"/>
    </chart:SfChart.Behaviors>

    <local:LineSeriesExt ItemsSource="{Binding Data}"
                         XBindingPath="XValue"
                         YBindingPath="YValue"
                         ShowTooltip="True"
                         Palette="Metro">
        <local:LineSeriesExt.AdornmentsInfo>
            <chart:ChartAdornmentInfo ShowLabel="True" Background="Transparent" 
                                      SymbolHeight="40" SymbolInterior="White"
                                      SymbolWidth="40" Symbol="Ellipse" 
                                      SymbolStroke="Black" ShowMarker="True" />
        </local:LineSeriesExt.AdornmentsInfo>
    </local:LineSeriesExt>
</chart:SfChart>

MainWindow-2023-02-13-10-33-56

Troubleshooting

Path too long exception

If you are facing a path too long exception when building this example project, close Visual Studio and rename the repository to a shorter name before building the project.

For more details, refer to the KB on how to restrict the tooltip on a WPF Chart.

See Also,
How to provide animation effects for tooltip?
How to customize the tooltip in chart?
How to view the tooltip when segment is underneath the axis line?