Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:49:08+00:00 2026-06-05T06:49:08+00:00

I have built a DataTemplateSelector which I use for showing a different pushpin on

  • 0

I have built a DataTemplateSelector which I use for showing a different pushpin on the map. I now have the following DataTemplate wich works in the way I want, except that it are not pushpins but textblocks which are shown on the map.

<DataTemplate x:Key="pushpinSelector">
    <my:Pushpin Location="{Binding Location}" Tap="Pushpin_Tap">
        <my:Pushpin.Template>
            <ControlTemplate>
                <local:PushpinTemplateSelector Content="{Binding}">
                    <local:PushpinTemplateSelector.ClusterTemplate>
                        <DataTemplate>
                            <TextBlock Text="Cluster" Width="100" Foreground="YellowGreen"></TextBlock>
                        </DataTemplate>
                    </local:PushpinTemplateSelector.ClusterTemplate>
                    <local:PushpinTemplateSelector.PushpinTemplate>
                        <DataTemplate>
                            <TextBlock Text="Pushpin" Width="100" Foreground="Blue"></TextBlock>
                        </DataTemplate>
                    </local:PushpinTemplateSelector.PushpinTemplate>
                </local:PushpinTemplateSelector>
            </ControlTemplate>
        </my:Pushpin.Template>
    </my:Pushpin>
</DataTemplate>

I would expect that it would work in the following format too:

<DataTemplate x:Key="pushpinSelector">
    <local:PushpinTemplateSelector Content="{Binding}">
        <local:PushpinTemplateSelector.ClusterTemplate>
            <DataTemplate>
                <my:Pushpin Location="{Binding Location}" Content="{Binding Count}" Foreground="YellowGreen"></my:Pushpin>
            </DataTemplate>
        </local:PushpinTemplateSelector.ClusterTemplate>
        <local:PushpinTemplateSelector.PushpinTemplate>
            <DataTemplate>
                <my:Pushpin Location="{Binding Location}" Foreground="Blue"></my:Pushpin>
            </DataTemplate>
        </local:PushpinTemplateSelector.PushpinTemplate>
    </local:PushpinTemplateSelector>
</DataTemplate>

But with this template it’s only showing 1 black pushpin on the map. Am I doing something wrong with the Bindings? I’am not seeing why this is not working in the expected way.

As requested by @localjoost the code for the datatemplateselector:

The abstract class:

public abstract class DataTemplateSelector : ContentControl
{
    public virtual DataTemplate SelectTemplate(
        object item, DependencyObject container)
    {
        return null;
    }

    protected override void OnContentChanged(object oldContent, object newContent)
    {
        base.OnContentChanged(oldContent, newContent);

        ContentTemplate = SelectTemplate(newContent, this);
    }
}

And the implementation of the abstract class:

     public class PushpinTemplateSelector : DataTemplateSelector
{
    public DataTemplate ClusterTemplate
    {
        get;
        set;
    }

    public DataTemplate PushpinTemplate
    {
        get;
        set;
    }

    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
        PushpinModel model = item as PushpinModel;

        if (model.CurrentObject == null)
        {
            return ClusterTemplate;
        }
        else
        {
            return PushpinTemplate;
        }
    }
}

And how I use the Datatemplate (which is defined in my application resources section) in my map control:

<my:Map Height="624" HorizontalAlignment="Left" Name="map1" VerticalAlignment="Top" Width="468" CredentialsProvider="XXXXX" 
        ZoomLevel="13">
    <my:MapItemsControl Name="pushPinModelsLayer" ItemsSource="{Binding PushpinModels}" ItemTemplate="{StaticResource pushpinSelector}" />
    <my:Pushpin Name="myLocation" Template="{StaticResource MyLocationTemplate}"></my:Pushpin>
</my:Map>

As far is I can see there’s not rocket science inside the pushpinselectortemplate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:49:09+00:00Added an answer on June 5, 2026 at 6:49 am

    Haven’t found a different approach than the first one described in the question. For now I will work with it in that way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a free version of a game app which is now on
I have built an application in which I use sqlite to store data. It
I have built a table which on of it's row is like so <tr
I have built and app which does random stuff and I want to collect
I have built a Fiddle on JSFiddle which retrieves an OAuth access token via
I have built an enumeration in javascript using the following syntax: MyEnum = {
I have built a music player which loads songs from a database in a
I have built up a number of common modules which I have been hitherto
I have built an executable which launches a dialog box in which is embedded
I have built-in tuple which looks like (u,v) . They are generated by Networkx

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.