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.
Unfortunately, activation email could not send to your email. Please try again.

Access to underlying object in Data Template

Thread ID:

Created:

Updated:

Platform:

Replies:

87886 Jul 12,2009 11:22 PM Mar 14,2011 04:31 AM WPF 5
loading
Tags: Chart
Marc Glick
Asked On July 12, 2009 11:22 PM

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?


Saradha [Syncfusion]
Replied On July 13, 2009 05:25 AM

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

Marc Glick
Replied On July 13, 2009 11:07 AM

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}" >





Saradha [Syncfusion]
Replied On July 14, 2009 02:14 AM

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

John Fairbanks
Replied On March 10, 2011 03:08 PM

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


Saravanan A [Syncfusion]
Replied On March 14, 2011 04:31 AM

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



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;