TemplateSelector refresh when object changes?

2 posts, 0 answers
  1. Louis
    Louis avatar
    86 posts
    Member since:
    Aug 2013

    Posted 01 Aug 2014 Link to this post

    In my app, I have 4 data templates that represent the state of points on the chart. This all works fine when first drawn, and my TemplateSelector assigns the proper template to the point based on the state of the underlying object.

    My problem is that when the underlying object changes, I need it to trigger a refresh of that point, to get the chart to re-evaluate the TemplateSelector to apply the correct DataTemplate to reflect the new state. Is there any way to set up a binding, or absent that a way to poke it from the code-behind in a way that's not terribly horrible and get it to re-plot a single point? The only way I've found is to re-plot the whole series, which is a big performance issue with large datasets (10-50k items).

  2. Petar Marchev
    Petar Marchev avatar
    1029 posts

    Posted 04 Aug 2014 Link to this post

    Hi Louis,

    Unfortunately the templаte selector functionality of the series works series-wise and not point-wise and it is not possible to reevaluate the template of a single point. If this performance hit is very large, perhaps you can implement your own data-template-selector logic by using only the PointTemplate property of the series. In the template you can define your own visual that chooses its template based on the data-point (data-item) at hand. In that visual you can also implement logic that observes if the template should be changed.

    Note that the approach described above may not be a very good idea if you have zooming on. This is because the chart has a virtualization mechanism where the content presenters are reused. This may result in you custom visuals changing their templates way too often, thus resulting in a more prominent performance loss.

    Another option is for you to use different series for the different templates. You mention having 4 templates. Perhaps you can use 4 different series and when the template of the point needs to be changed, simply move the item in the desired collection.

    Petar Marchev
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top