This is a migrated thread and some comments may be shown as answers.

DataPointTemplate in code

5 Answers 94 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steven
Top achievements
Rank 1
Steven asked on 21 Sep 2012, 11:40 AM
Hi,

just wondering how to instantiate and assign a data point template to a series in code, not XAML.

Is this possible?

5 Answers, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 21 Sep 2012, 01:16 PM
Hello Steven,

The easiest way would be a "hybrid" approach with XamlReader.Load(...) like this:
BarSeries series = new BarSeries();
series.PointTemplate = System.Windows.Markup.XamlReader.Load(@"
<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
    <Rectangle Fill=""Yellow"" HorizontalAlignment=""Stretch"" VerticalAlignment=""Stretch"" />
</DataTemplate>") as DataTemplate;


Greetings,
Bart.
0
Steven
Top achievements
Rank 1
answered on 21 Sep 2012, 01:29 PM
thanks for the response.

is a slightly harder way possible with new ABC() { veriousProperies = X} possible?
0
Steven
Top achievements
Rank 1
answered on 25 Sep 2012, 12:33 PM
Telerik: Is the parse method the only way forward?
0
Giuseppe
Telerik team
answered on 26 Sep 2012, 08:15 AM
Hello Steven,

Yes, this is the only way in Silverlight -- check this msdn article here ("The XAML usage that defines the content for creating a data template is not exposed as a settable property. It is special behavior built into the XAML processing of a DataTemplate object element.").


Kind regards,
Giuseppe
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Steven
Top achievements
Rank 1
answered on 01 Oct 2012, 05:52 AM
thanks for suggesting this direction.  I'm getting better at debugging and mostly attribute errors to parse or namespace errors now.  It seems a bit of a waste of XAML power to need to do it this way, but so long as it is used sparingly I guess this is okay.
Tags
ChartView
Asked by
Steven
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
Steven
Top achievements
Rank 1
Giuseppe
Telerik team
Share this question
or