menu

WPF

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ChartTooltipBehavior - WPF API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ChartTooltipBehavior

    ChartTooltipBehavior displays tooltip for the data points nearer to mouse over position or at touch contact point inside a chart area when ShowTooltip property is true.

    Inheritance
    System.Object
    ChartBehavior
    ChartTooltipBehavior
    Implements
    ICloneable
    Inherited Members
    ChartBehavior.AdorningCanvas
    ChartBehavior.AlignDefaultLabel(ChartAlignment, ChartAlignment, Double, Double, ContentControl)
    ChartBehavior.AttachElements()
    ChartBehavior.BottomAdorningCanvas
    ChartBehavior.ChartArea
    ChartBehavior.chartAxis
    ChartBehavior.Clone()
    ChartBehavior.DetachElement(UIElement)
    ChartBehavior.DetachElements()
    ChartBehavior.GetYValuesBasedOnIndex(Double, ChartSeriesBase)
    ChartBehavior.OnDoubleTapped(MouseButtonEventArgs)
    ChartBehavior.OnDragEnter(DragEventArgs)
    ChartBehavior.OnDragLeave(DragEventArgs)
    ChartBehavior.OnDragOver(DragEventArgs)
    ChartBehavior.OnDrop(DragEventArgs)
    ChartBehavior.OnGotFocus(RoutedEventArgs)
    ChartBehavior.OnKeyDown(KeyEventArgs)
    ChartBehavior.OnKeyUp(KeyEventArgs)
    ChartBehavior.OnLayoutUpdated()
    ChartBehavior.OnLostFocus(RoutedEventArgs)
    ChartBehavior.OnManipulationCompleted(ManipulationCompletedEventArgs)
    ChartBehavior.OnManipulationDelta(ManipulationDeltaEventArgs)
    ChartBehavior.OnManipulationStarted(ManipulationStartedEventArgs)
    ChartBehavior.OnMouseEnter(MouseEventArgs)
    ChartBehavior.OnMouseLeave(MouseEventArgs)
    ChartBehavior.OnMouseLeftButtonDown(MouseButtonEventArgs)
    ChartBehavior.OnMouseLeftButtonUp(MouseButtonEventArgs)
    ChartBehavior.OnMouseMove(MouseEventArgs)
    ChartBehavior.OnMouseWheel(MouseWheelEventArgs)
    ChartBehavior.UpdateArea()
    Namespace: Syncfusion.UI.Xaml.Charts
    Assembly: Syncfusion.SfChart.WPF.dll
    Syntax
    public class ChartTooltipBehavior : ChartBehavior, ICloneable
    Remarks

    The ChartTooltipBehavior is commonly used for all series to customize the tooltip. You can use the attached ChartTooltip properties in a series if you need to customize the appearance of the tooltip based on a particular series. Series attached properties is considered as high precedence.

    Examples
    • XAML
    • C#
    <syncfusion:SfChart>
       <syncfusion:SfChart.Behaviors>
           <syncfusion:ChartTooltipBehavior/>
       </syncfusion:SfChart.Behaviors>
    </syncfusion:SfChart>
    ChartTooltipBehavior tooltip = new ChartTooltipBehavior();
    chartArea.Behaviors.Add(tooltip);

    Constructors

    ChartTooltipBehavior()

    Initializes a new instance of the ChartTooltipBehavior.

    Declaration
    public ChartTooltipBehavior()

    Fields

    EnableAnimationProperty

    Identifies the EnableAnimation dependency property.

    Declaration
    public static readonly DependencyProperty EnableAnimationProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the EnableAnimation dependency property.

    HorizontalAlignmentProperty

    Identifies the HorizontalAlignment dependency property.

    Declaration
    public static readonly DependencyProperty HorizontalAlignmentProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the HorizontalAlignment dependency property.

    HorizontalOffsetProperty

    Identifies the HorizontalOffset dependency property.

    Declaration
    public static readonly DependencyProperty HorizontalOffsetProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the HorizontalOffset dependency property.

    InitialShowDelayProperty

    Identifies the InitialShowDelay dependency property.

    Declaration
    public static readonly DependencyProperty InitialShowDelayProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the InitialShowDelay dependency property.

    LabelStyleProperty

    Identifies the LabelStyle dependency property.

    Declaration
    public static readonly DependencyProperty LabelStyleProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the LabelStyle dependency property.

    PositionProperty

    Identifies the Position dependency property.

    Declaration
    public static readonly DependencyProperty PositionProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the Position dependency property.

    ShowDurationProperty

    Identifies the ShowDuration dependency property.

    Declaration
    public static readonly DependencyProperty ShowDurationProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the ShowDuration dependency property.

    StyleProperty

    Identifies the Style dependency property.

    Declaration
    public static readonly DependencyProperty StyleProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the Style dependency property.

    VerticalAlignmentProperty

    Identifies the VerticalAlignment dependency property.

    Declaration
    public static readonly DependencyProperty VerticalAlignmentProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the VerticalAlignment dependency property.

    VerticalOffsetProperty

    Identifies the VerticalOffset dependency property.

    Declaration
    public static readonly DependencyProperty VerticalOffsetProperty
    Field Value
    Type Description
    System.Windows.DependencyProperty

    The identifier for the VerticalOffset dependency property.

    Properties

    EnableAnimation

    Gets or sets the value that indicates whether to enable the animation when showing tooltip.

    Declaration
    public bool EnableAnimation { get; set; }
    Property Value
    Type Description
    System.Boolean

    bool. The default value is true.

    Examples
    • XAML
    • C#
    <chart:SfChart.Behaviors>
        <chart:ChartTooltipBehavior x:Name="chartTooltipBehavior" EnableAnimation="true"/>
    </chart:SfChart.Behaviors>
    ChartTooltipBehavior chartTooltipBehavior = new ChartTooltipBehavior();
    chartTooltipBehavior.EnableAnimation = true;
    chart.Behaviors.Add(chartTooltipBehavior);

    HorizontalAlignment

    Gets or sets the horizontal alignment of tooltip label with respect to the cursor position.

    Declaration
    public HorizontalAlignment HorizontalAlignment { get; set; }
    Property Value
    Type Description
    System.Windows.HorizontalAlignment

    HorizontalAlignment. The default value is HorizontalAlignment.Center.

    Examples
    • XAML
    • C#
    <chart:SfChart.Behaviors>
       <chart:ChartTooltipBehavior x:Name="chartTooltipBehavior" HorizontalAlignment="Right"/>
    </chart:SfChart.Behaviors>
    ChartTooltipBehavior chartTooltipBehavior = new ChartTooltipBehavior();
    chartTooltipBehavior.HorizontalAlignment = HorizontalAlignment.Right;
    chart.Behaviors.Add(chartTooltipBehavior);

    HorizontalOffset

    Gets or sets the value to position the tooltip at a distance from the cursor horizontally.

    Declaration
    public double HorizontalOffset { get; set; }
    Property Value
    Type Description
    System.Double

    double. The default value is 0.

    Remarks

    The HorizontalOffset property and the VerticalOffset property values provide additional adjustment to position the tooltip.

    Examples
    • XAML
    • C#
    <chart:SfChart.Behaviors>
       <chart:ChartTooltipBehavior x:Name="chartTooltipBehavior" HorizontalOffset="10"/>
    </chart:SfChart.Behaviors>
    ChartTooltipBehavior chartTooltipBehavior = new ChartTooltipBehavior();
    chartTooltipBehavior.HorizontalOffset = 10;
    chart.Behaviors.Add(chartTooltipBehavior);

    InitialShowDelay

    Gets or sets the delay in milliseconds to show the tooltip once user interact with series.

    Declaration
    public int InitialShowDelay { get; set; }
    Property Value
    Type Description
    System.Int32

    integer. The default value is 0 milliseconds.

    Remarks

    Used to specify the amount of time before the user has to wait when hover the mouse or touch on chart series in milliseconds before tooltip display.

    Note: Initial delay only works for the positive values.

    Examples
    • XAML
    • C#
    <chart:SfChart.Behaviors>
       <chart:ChartTooltipBehavior x:Name="chartTooltipBehavior" InitialShowDelay="1000"/>
    </chart:SfChart.Behaviors>
    ChartTooltipBehavior chartTooltipBehavior = new ChartTooltipBehavior();
    chartTooltipBehavior.InitialShowDelay = 1000;
    chart.Behaviors.Add(chartTooltipBehavior);

    LabelStyle

    Gets or sets the style to customize the tooltip label.

    Declaration
    public Style LabelStyle { get; set; }
    Property Value
    Type Description
    System.Windows.Style

    The Style for tooltip label.

    Remarks

    To define a Style for tooltip label, specify the style of TargetType as TextBlock.

    Examples
    • XAML
    • C#
    <syncfusion:SfChart.Resources>
        <Style TargetType="TextBlock" x:Key="labelStyle">
           <Setter Property="FontSize" Value="14"/>
           <Setter Property="Foreground" Value="Red"/>
        </Style>
    </syncfusion:SfChart.Resources>
    <syncfusion:SfChart.Behaviors>
       <syncfusion:ChartTooltipBehavior LabelStyle = {StaticResource labelStyle}/>
    </syncfusion:SfChart.Behaviors>
    SfChart chart = new SfChart();
    Style labelStyle = new Style(typeof(TextBlock));
    labelStyle.Setters.Add(new Setter(TextBlock.FontSizeProperty, 14d));
    labelStyle.Setters.Add(new Setter(TextBlock.ForegroundProperty, new SolidColorBrush(Colors.Red)));
    ChartTooltipBehavior tooltipBehavior = new ChartTooltipBehavior();
    tooltipBehavior.LabelStyle = labelStyle;
    chart.Behaviors.Add(tooltipBehavior);

    Position

    Gets or sets a value that indicates whether to position the tooltip at data point position or at cursor position.

    Declaration
    public TooltipPosition Position { get; set; }
    Property Value
    Type Description
    TooltipPosition

    TooltipPosition. The default value is Auto.

    Remarks

    When the TooltipPosition is set as Auto the tooltip will be displayed at the data point position while hover mouse inside any chart segment. If the TooltipPosition is set as Pointer then the tooltip will be displayed in conjunction with the mouse pointer itself while hover mouse inside any chart segment.

    Examples
    • XAML
    • C#
    <chart:SfChart.Behaviors>
        <chart:ChartTooltipBehavior x:Name="chartTooltipBehavior" Position="Pointer"/>
    </chart:SfChart.Behaviors>
    ChartTooltipBehavior chartTooltipBehavior = new ChartTooltipBehavior();
    chartTooltipBehavior.Position = TooltipPosition.Pointer;
    chart.Behaviors.Add(chartTooltipBehavior);

    ShowDuration

    Gets or sets the amount of time that the tooltip remains visible in milliseconds.

    Declaration
    public int ShowDuration { get; set; }
    Property Value
    Type Description
    System.Int32

    integer. The default value is 1000 milliseconds.

    Remarks

    This property defines the time that a tooltip remains visible while the user pauses the mouse pointer over the chart series area that defines the tooltip.

    Examples
    • XAML
    • C#
    <chart:SfChart.Behaviors>
       <chart:ChartTooltipBehavior x:Name="chartTooltipBehavior" ShowDuration="3000"/>
    </chart:SfChart.Behaviors>
    ChartTooltipBehavior chartTooltipBehavior = new ChartTooltipBehavior();
    chartTooltipBehavior.ShowDuration = 3000;
    chart.Behaviors.Add(chartTooltipBehavior);

    Style

    Gets or sets the style to customize the fill and stroke of tooltip.

    Declaration
    public Style Style { get; set; }
    Property Value
    Type Description
    System.Windows.Style

    The Style for tooltip.

    Remarks

    To define a Style for tooltip, specify the style of TargetType as Path.

    Examples
    • XAML
    • C#
    <syncfusion:SfChart.Resources>
        <Style TargetType="Path" x:Key="style">
           <Setter Property="Stroke" Value="Black"/>
           <Setter Property="Fill" Value="Gray"/>
        </Style>
    </syncfusion:SfChart.Resources>
    <syncfusion:SfChart.Behaviors>
        <syncfusion:ChartTooltipBehavior Style = {StaticResource style}/>
    </syncfusion:SfChart.Behaviors>
    SfChart chart = new SfChart();
    Style style = new Style(typeof(Path));
    style.Setters.Add(new Setter(Path.StrokeProperty, new SolidColorBrush(Colors.Black)));
    style.Setters.Add(new Setter(Path.FillProperty, new SolidColorBrush(Colors.Gray)));
    ChartTooltipBehavior tooltipBehavior = new ChartTooltipBehavior();
    tooltipBehavior.Style = style;
    chart.Behaviors.Add(tooltipBehavior);

    VerticalAlignment

    Gets or sets the vertical alignment of tooltip label with respect to the cursor position.

    Declaration
    public VerticalAlignment VerticalAlignment { get; set; }
    Property Value
    Type Description
    System.Windows.VerticalAlignment

    VerticalAlignment. The default value is VerticalAlignment.Top.

    Examples
    • XAML
    • C#
    <chart:SfChart.Behaviors>
       <chart:ChartTooltipBehavior x:Name="chartTooltipBehavior" VerticalAlignment="Bottom"/>
    </chart:SfChart.Behaviors>
    ChartTooltipBehavior chartTooltipBehavior = new ChartTooltipBehavior();
    chartTooltipBehavior.VerticalAlignment = VerticalAlignment.Bottom;
    chart.Behaviors.Add(chartTooltipBehavior);

    VerticalOffset

    Gets or sets the value to position the tooltip at a distance from the cursor vertically.

    Declaration
    public double VerticalOffset { get; set; }
    Property Value
    Type Description
    System.Double

    double. The default value is 0.

    Remarks

    The HorizontalOffset property and the VerticalOffset property values provide additional adjustment to position the tooltip.

    Examples
    • XAML
    • C#
    <chart:SfChart.Behaviors>
        <chart:ChartTooltipBehavior x:Name="chartTooltipBehavior" VerticalOffset="10"/>
    </chart:SfChart.Behaviors>
    ChartTooltipBehavior chartTooltipBehavior = new ChartTooltipBehavior();
    chartTooltipBehavior.VerticalOffset = 10;
    chart.Behaviors.Add(chartTooltipBehavior);

    Methods

    CloneBehavior(DependencyObject)

    Returns the instance of ChartTooltipBehavior.

    Declaration
    protected override DependencyObject CloneBehavior(DependencyObject obj)
    Parameters
    Type Name Description
    System.Windows.DependencyObject obj

    object.

    Returns
    Type Description
    System.Windows.DependencyObject

    The cloned ChartTooltipBehavior.

    Overrides
    ChartBehavior.CloneBehavior(DependencyObject)

    OnSizeChanged(SizeChangedEventArgs)

    Declaration
    protected override void OnSizeChanged(SizeChangedEventArgs e)
    Parameters
    Type Name Description
    System.Windows.SizeChangedEventArgs e
    Overrides
    ChartBehavior.OnSizeChanged(SizeChangedEventArgs)

    Implements

    ICloneable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved