We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display underlying model data in tooltip?

Platform: UWP |
Control: SfChart |
Published Date: January 27, 2016 |
Last Revised Date: June 27, 2019


The chart series tooltip shows YData of the series, by default. The SfChart allows you to display the underlying model of the series in tooltip. This article describes how to show the underlying model.


In series, each segment holds the corresponding underlying model in the Item property. To display the tooltip from the underlying model, use the ToolTipTemplate property. In that template, you can bind the Item property of the segment to the Text property of the TextBlock as illustrated in the following code.


<!—ToolTipTemplate for the series -->
    <DataTemplate x:Key="tooltipTemplate">
        <Border BorderBrush="Brown" BorderThickness="3">
                <StackPanel Background="PaleGreen" >
                    <TextBlock Text="Value : " Margin="5"  
                       VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="13" FontWeight="Bold"/>
                    <TextBlock Text="Text : " Margin="5" 
                       VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="13" FontWeight="Bold"/>
                <StackPanel Background="PaleGreen" Grid.Column="1">
                    <TextBlock Text="{Binding YData,StringFormat=N}" Margin="5" 
                       VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="13" FontWeight="Bold"/>
                    <TextBlock Text="{Binding Item.Text}" Margin="5" 
                       VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="13" FontWeight="Bold"/>
<!—Adding Chart -->
<chart:SfChart x:Name="chart" Margin="10" Header="Product Details" FontSize="18">
        <chart:CategoryAxis Header="Product ID"/>
        <chart:NumericalAxis Header="Value"/>
    <chart:ColumnSeries XBindingPath="ProdId" YBindingPath="Price" ItemsSource="{Binding Products}" TooltipTemplate="{StaticResource tooltipTemplate}" ShowTooltip="True" />


public MainWindow()
private void GetSeries()
    ColumnSeries series = new ColumnSeries();
    ViewModel obj = new ViewModel();
    series.ItemsSource = obj.Products;
    series.XBindingPath = "ProdId";
    series.YBindingPath = "Price";
    series.ShowTooltip = true;
    series.TooltipTemplate = SetToolTipTemplate();
private DataTemplate SetToolTipTemplate()
    DataTemplate template = new DataTemplate();
    FrameworkElementFactory txtblock = new FrameworkElementFactory(typeof(TextBlock));
    txtblock.SetValue(TextBlock.WidthProperty, 85.0);
    txtblock.SetValue(TextBlock.HeightProperty, 25.0);
    txtblock.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
    txtblock.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
    txtblock.SetValue(TextBlock.FontSizeProperty, 15.0);
    Binding binding = new Binding();
    binding.Path = new PropertyPath("YData");
    txtblock.SetValue(TextBlock.TextProperty, binding);
    FrameworkElementFactory txtblock1 = new FrameworkElementFactory(typeof(TextBlock));
    txtblock1.SetValue(TextBlock.WidthProperty, 85.0);
    txtblock1.SetValue(TextBlock.HeightProperty, 25.0);
    txtblock1.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
    txtblock1.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
    Binding binding1 = new Binding();
    binding1.Path = new PropertyPath("Item.Text");//Gets the Price property value from Observable collection.
    txtblock1.SetValue(TextBlock.TextProperty, binding1);
    FrameworkElementFactory grid = new FrameworkElementFactory(typeof(StackPanel));
    template.VisualTree = grid;
    return template;

The following screenshot displays the tooltip with underlying model data.


Chart tooltip with underlaying model in WPF

Figure 1: Tooltip with underlying model data.

2X faster development

The ultimate UWP UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon