Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
how to display itemtooltip in Scatter series
posted

Hello,

Can someone share code snippet on activating tooltip value when user hovers on a scatter point of the scatter series?

I have built scatter series in the code behind and all I want to add is the ability to see the values (both X and Y) when user hovers it.

  • 34510
    Verified Answer
    Offline posted

    Hi Priyank,

    The scatter series has a ToolTip property which you can set to some FrameworkElement that you want to use to represent your tooltip.  Since you are creating the series in code behind, an easy way to handle this is to create a DataTemplate in your XAML that defines what your tooltip will look like.  Then in code behind you can call DataTemplate.LoadContent() in order to instantiate this tooltip content.  Ex:

    XAML:

    <DataTemplate x:Key="ToolTipTemplate">
        <Grid>
            <TextBlock Text="{Binding Item.ValueProperty}"/>
        </Grid>
    </DataTemplate>

    Code behind:

    var series = new ScatterSeries();
    series.ItemsSource = mydata;
    series.XMemberPath = "X";
    series.YMemberPath = "Y";
    series.XAxis = xAxis;
    series.YAxis = yAxis;

    var dt = Resources["ToolTipTemplate"] as DataTemplate;
    series.ToolTip = dt.LoadContent();