Map.Center Property
May 02, 2013
Gets or sets the center of the map control.
Assembly: Microsoft.Phone.Maps (in Microsoft.Phone.Maps.dll)
[TypeConverterAttribute(typeof(GeoCoordinateConverter))] public GeoCoordinate Center { get; set; }
Property Value
Type: System.Device.Location.GeoCoordinateThe center in GeoCoordinate of the map control.
If you try to change the center by providing a new GeoCoordinate that is less than two centimeters (2 cm.) from the current center, the change is ignored.
After you set the value of the TransformCenter property for the Map control, the Center property continues to return the previous center until you set the Center to the same value as the TransformCenter.
Don’t use the Latitude property and the Longitude property to set the center of the Map control. Instead, create a new GeoCoordinate object and assign it to the Center property.
The following code example shows how you can set the center of Map by using XAML.
<!--ContentPanel - place additional content here--> <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <maps:Map x:Name="MyMap" Center="47.6097, -122.3331" /> </Grid>
The following code example shows how can set the center of Map using code.
// Constructor
public MainPage()
{
InitializeComponent();
Map MyMap = new Map();
MyMap.Center = new GeoCoordinate(47.6097, -122.3331);
ContentPanel.Children.Add(MyMap);
}