I am having a binding issue with the tooltip in my xamdatachart.
Below is the snippet where I call it in my chartcallback event:
if (line.Description == "Datum Pressure VS Test Date") {
var tooltipTemplate = Application.Current.TryFindResource("PressureTestToolTipTemplate");
if (tooltipTemplate != null){
var tooltip = new ContentControl();
tooltip.DataContext = tooltip.ContentTemplate = (DataTemplate) tooltipTemplate;
series.ToolTip = tooltip;
}}
Below is the datatemplate where the binding occurs:
<TextBlock Style="{DynamicResource Navigation}" Text="Type: "/>
<TextBlock Style="{DynamicResource Navigation}"
Text="{Binding Item.TestType.Value.Value}" />
This line "Text="{Binding Item.TestType.Value.Value}" />" should be bound to dynamic value that changes. It shows up empty, when it shouldn't. is there something I am missing/doing wrong?
Hi Keicha,
When using a ContentControl, the DataContext of the ContentControl is not automatically passed down to the content inside the DataTemplate. The DataContext of the content inside the DataTemplate is set to the Content property from the ContentControl. So what you should do is bind the ContentControl.Content to it's DataContext which will eventually be set to a Infragistics.Controls.Charts.DataContext instance by the chart. Inside this instance is an Item property which contains your data point.
var tooltip = new ContentControl(); BindingOperations.SetBinding(tooltip, ContentControl.ContentProperty, new Binding()); tooltip.ContentTemplate = (DataTemplate)tooltipTemplate;
This worked! I appreciate your help :)
You're very welcome. Glad I could help.