DataPointTemplate in code

6 posts, 0 answers
  1. Steven
    Steven avatar
    22 posts
    Member since:
    May 2011

    Posted 21 Sep 2012 Link to this post

    Hi,

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

    Is this possible?
  2. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 21 Sep 2012 Link to this post

    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.
  3. DevCraft banner
  4. Steven
    Steven avatar
    22 posts
    Member since:
    May 2011

    Posted 21 Sep 2012 Link to this post

    thanks for the response.

    is a slightly harder way possible with new ABC() { veriousProperies = X} possible?
  5. Steven
    Steven avatar
    22 posts
    Member since:
    May 2011

    Posted 25 Sep 2012 Link to this post

    Telerik: Is the parse method the only way forward?
  6. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 26 Sep 2012 Link to this post

    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.

  7. Steven
    Steven avatar
    22 posts
    Member since:
    May 2011

    Posted 01 Oct 2012 Link to this post

    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.
Back to Top
DevCraft banner