0

I am new to silverlight and hence new to Bing Map Control as well. Here's what i am trying to achieve

I've a viewmodel which has 2 properties and looks like this...

public class Vm : INotifyPropertyChanged
{
    private LocationCollection _locations;

    public LocationCollection Locations
    {
        get { return _locations; }
        set
        {
            _locations = value;
            this.Notify("Locations");
        }
    }

    private Location _selectedLocation;

    public Location SelectedLocation
    {
        get { return _selectedLocation; }
        set
        {
            _selectedLocation = value;
            this.Notify("SelectedLocation");
        }
    }

    protected virtual void Notify(string property)
    {
        if( null != this.PropertyChanged)
        {
            PropertyChangedEventArgs e = new PropertyChangedEventArgs(property);
            this.PropertyChanged(this,e);
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
}

In my XAML I have a listbox and a Bing Map control. The listbox is bound to locations (Display member is a Latitude for now) and the map control has a MapsItemControl which is bound to Locations as well. The SelectedItem of ListBox is bound to SelectedLocation and The Center of the map is bound to SelectedLocation as well. So the xaml looks like this

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <ListBox ItemsSource="{Binding Path=Locations}"
             SelectedItem="{Binding Path=SelectedLocation, Mode=TwoWay}"
             DisplayMemberPath="Latitude"
             Grid.Row="0"/>

    <map:Map
        Grid.Row="1"
        CredentialsProvider="Av2K1aKwZLPJRS-F_m1TGlFg2bPFVVDgMGbxfFp-1rdpUrwfQmiPSouaSHrHoK-j" 
        Loaded="Map_Loaded"
        Center="{Binding Path=SelectedLocation, Mode=TwoWay}"
        ZoomLevel="17">
        <map:MapItemsControl x:Name="mapItemsControl" ItemsSource="{Binding Path=Locations}">
            <map:MapItemsControl.ItemTemplate>
                <DataTemplate>
                    <map:Pushpin 
                        Location="{Binding}"
                        />
                </DataTemplate>
            </map:MapItemsControl.ItemTemplate>
        </map:MapItemsControl>
    </map:Map>
</Grid>

As i select the items in the listbox i am able to see that the center of the map changes. However i want to change the Template of Pushpin in this case as well. Let's say that i want to display an image instead of the OOB Pushpin. I understand the concept of how to customize the pushpin however i am unable to get any selection states in MapsItemControl similar to what i can find in other ItemsControl like listbox etc. Can someone help me on this ??

Matt
  • 14,353
  • 5
  • 53
  • 65
Abhishek
  • 1
  • 1

1 Answers1

0

You could add another MapItemsControl that was bound to only your SelectedLocation and have the other MapItemsControl be bound to all the locations except the SelectedLocation.

That way you could have seperate templates for the selected ones and the unselected ones.

schummbo
  • 890
  • 4
  • 14