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
1495
XamDataChart tooltip datatemplate for all series
posted

Hi team,

  • We are using MVVM design pattern and want to display data in XamDataChart with StackedColumnSeries.
  • We defined series in xaml and want to show tooltip of every series, its very tough for us to write same code of tooltip for every series.
  • We make a template of tooltip and want to use that template in all series, but when we set that template in series tooltip its not working.
  • How can we set datatemplate for every series ?
  • Sample application is attached. 
XamDataChart.zip
Parents
No Data
Reply
  • 34510
    Offline posted

    Hello elinder,

    With the way the tooltip is defined, it doesn't need to be placed on every StackedFragmentSeries.  It only needs to be placed on the StackedColumnSeries.  This is because the template already displays the values presented by the StackedFragmentSeries, so there's no need to place a tooltip on each individual fragment series if they are all going to show the same data anyway.

    The reason the tooltips aren't working is because DataTemplates cannot be assigned to the ToolTip directly.  The tooltip needs to be assigned to a control and inside that control you can place something like a ContentPresenter to use your template. 

    <ig:StackedColumnSeries.ToolTip>
        <Grid>
            <ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource TooltipTemplate}"/>
        </Grid>
    </ig:StackedColumnSeries.ToolTip>

     

    I have attached a modified version of your sample that you can take a look at.  Let me know if you have any questions.

    XamDataChart_modified.zip
Children