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
3220
xamDataChart: Custom tooltip on multiple series
posted

Hello,

I have xamDataChart, with mulitple series, and to want show a custom tooltip. When defining a DataTemplate the Item contains the List where the data are displayed. So it requires an index of that list to get it properties.

<DataTemplate x:Key="tooltipTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,5,0">
                    <Run Text="{Binding Path=Series.Title}"/><Run Text=":"/>
                </TextBlock>
                <TextBlock Grid.Row="0" Grid.Column="1">
                    <Run Text="{Binding Path=Item.Value, StringFormat={}{0:0.##}, Mode=OneWay}"/>
                    <Run Text="{Binding Path=Item}"/>
                </TextBlock>
            </Grid>
        </DataTemplate>

Error message:

System.Windows.Data Error: 40 : BindingExpression path error: 'Value' property not found on 'object' ''CategoryGroupSerieData' (HashCode=31324050)'. BindingExpression:Path=Item.Value; DataItem='DataContext' (HashCode=13481002); target element is 'Run' (HashCode=2912325); target property is 'Text' (type 'String')

In code behehind I add that resource to the proper series:

var toolTip = new ContentControl();
                toolTip.ContentTemplate = FindResource("tooltipTemplate") as DataTemplate;
                toolTip.SetBinding(ContentProperty, new Binding());
                series.ToolTip = toolTip;

How can I access the data item of the proper series in the tooltip template?

Top Replies

Parents Reply Children
No Data