I am trying to work with WP7 and Bingmaps.
I have this code
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<my:Map Height="389" HorizontalAlignment="Left" Margin="28,28,0,0" Name="map1" VerticalAlignment="Top" Width="409" />
</Grid>
and
public MapInfo()
{
InitializeComponent();
GeoCoordinate lHamburg = new GeoCoordinate(53.550556, 9.993333);
//map1.Radius = 5000;
map1.ZoomLevel = 10.0;
map1.Center = lHamburg;
map1.CredentialsProvider = new ApplicationIdCredentialsProvider(APPLICATION_ID);
//Add a pin to the map
Pushpin pushpin = new Pushpin();
Location loc开发者_开发技巧ation = new Location();
location.Latitude = 53.550556;
location.Longitude = 9.993333;
pushpin.Location = location;
map1.Children.Add(pushpin);
}
But my pushpin is black, without any style. Did I forget something?
Thanks, Oscar
Edit: it looks like that they ARE black. I would have to set some style to it or something like that. Anyone could give me some hints of how to add a simple style? Very simple, maybe only change the color, or make it round like google maps or something like that.
Thanks, Oscar
You can use a style for example:
<Style TargetType="my:Pushpin">
<Setter Property="Background"
Value="White" />
</Style>
or directly set color while creating them:
//Add a pin to the map
Pushpin pushpin = new Pushpin();
Location location = new Location();
location.Latitude = 53.550556;
location.Longitude = 9.993333;
pushpin.Location = location;
pushpin.Background = new SolidColorBrush(Colors.Red);
map1.Children.Add(pushpin);
[NOTE: I used background property here. You may need to set different property/properties to change it's appearance to needed state.]
The following MSDN exercise will provide you with all the information that you need: Exercise 2: Handling and Customizing Pushpins. Scroll down to item 5 which is where the customizations of pushpins begins.
精彩评论