ClusterTemplateSelector or ItemTemplateSelector of a Visualization layer with a Clustered Data Sourse

4 posts, 1 answers
  1. vinutha
    vinutha avatar
    11 posts
    Member since:
    Dec 2014

    Posted 19 Dec 2014 Link to this post


      I want to have 2 types of clusters to be displayed on My Map . 

     <telerik:VisualizationLayer x:Name="visualizationLayer"
    ClusterTemplateSelector="{StaticResource predictionPinsDataTemplateSelector}"  
    ItemTemplate="{StaticResource ClusteredItemTemplate}"
     ItemsSource="{StaticResource MassiveDataSource}">

    Inside the template selector call I am making my decision of which template to be displayed. But i and not able to find the datatemplate . Below is the exception i get .  I have also attached the Sample project . Could you please help me out in this.ClusterSample    

  2. vinutha
    vinutha avatar
    11 posts
    Member since:
    Dec 2014

    Posted 23 Dec 2014 Link to this post

    Can any one help me out on this. 
  3. Answer
    Petar Mladenov
    Petar Mladenov avatar
    2992 posts

    Posted 24 Dec 2014 Link to this post

    Hi Vinutha,

    Generally, looking up a resource in code behind is bad idea - it will be slower and far away from MVVM pattern. The DataTemplateSelector should be usually used with properties which you use both in XAML - to set them and in code behind (in SelectTemplate method) to select them. 

    For example you can check the RadTreeView ItemTemplateSelector help article.

    In your scenario you can add DataTemplate properties in your PredictionPinsDataTemplateSelector, for example "FirstClusterTemplate" and "SecondClusterTemplate". In SelectTemplate method you need to return for example this.FirstClusterTemplate based on some logic. In XAML, you must first define the FirstClusterTemplate and SecondClusterTemplate and below them you need to have:
    <clusteredDataSorceSample: PredictionPinsDataTemplateSelector
                             FirstClusterTemplate={StaticResource firstDataTemplate}
                              SecondClusterTemplate={StaticResource secondClusterTemplate} ...

    Petar Mladenov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  4. vinutha
    vinutha avatar
    11 posts
    Member since:
    Dec 2014

    Posted 29 Dec 2014 Link to this post

    Thank you so much this resolved my issue.
Back to Top