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

Access to underlying object in Data Template

Is there any way to access the underlying data item a chart is bound to in a data template.

Right now it seems as the only data available is what you bind via BindingPathX and BindingPathsY. If my underlying object has other properties I wish to visualize on the chart, how can I do that?


5 Replies

SA Saradha Syncfusion Team July 13, 2009 09:25 AM UTC

Hi Marc,

Thanks for your interest in Syncfusion products.

We could access the underlying Data Source and retrieve its properties. Please refer to the sample from the below given link.
http://files.syncfusion.com/support/Chart.WPF/7.3.0.6/F87886/main.htm

It uses a Data Template for Colum chart. A converter is used in this DataTemplate to retrieve the Data Source and its properties.

Please let me know if I have misunderstood your requirement.

Thank you,
K. Saradha Devi


MG Marc Glick July 13, 2009 03:07 PM UTC

Thanks for the prompt response. It also seems as the Tag property holds a reference to the underlying bound object. Can I rely on this. I prefer not having to use ValueConverters for simple tasks. For example, re-templating the candle to render candles with different fills.

Assume I extend the StockDataPoint class from your FinancialChart sample, and add an IsUp property.

Then I can retemplate the chart series as follows using
"CorrespondingPoints[0].DataPoint.Tag.IsUp"?



StrokeThickness="{Binding StrokeThickness}"
X1="{Binding HighX}" X2="{Binding LowX}"
Y1="{Binding HighY}" Y2="{Binding LowY}" />
Canvas.Left="{Binding X}" Canvas.Top="{Binding Y}"
Width="{Binding Width}" Height="{Binding Height}"
Stroke="{Binding Stroke}" StrokeThickness="{Binding
StrokeThickness}" ToolTip="{Binding ToolTip}" >






SA Saradha Syncfusion Team July 14, 2009 06:14 AM UTC

Hi Marc,

Thanks for your interest in Syncfusion products.

We could also write templates and access underlying data source values with tag property. We have created a sample, with StockDataPoint class with IsUp property and applied the same template provided by you.

Please refer to the modified sample in the below given link.
http://files.syncfusion.com/support/Chart.WPF/7.3.0.6/F87886/main.htm

Please let us know if you have further queries.

Regards,
K. Saradha Devi


JF John Fairbanks March 10, 2011 08:08 PM UTC

These sample links don't seem to work any more... I'd love to see these samples if I could.



SA Saravanan A Syncfusion Team March 14, 2011 08:31 AM UTC

Hi John,

Thanks for your interest in Syncfusion products.

Please find last sample provided for this forum in below location.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Accessing_Data_source_Properties1482509436.zip

Please let us know if you need any further clarifications.

Regards,
Saravanan



Loader.
Live Chat Icon For mobile
Up arrow icon