Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Map.Center Property

April 12, 2014

Gets or sets the location of the center of the Map.

Namespace:  Microsoft.Phone.Maps.Controls
Assembly:  Microsoft.Phone.Maps (in Microsoft.Phone.Maps.dll)
[TypeConverterAttribute(typeof(GeoCoordinateConverter))]
public GeoCoordinate Center { get; set; }

Property Value

Type: System.Device.Location.GeoCoordinate
The location of the center of the Map.

Don’t use the Latitude property and the Longitude property to set the center of the Map. Instead, create a new GeoCoordinate object and assign it to the Center property.

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, the Center property continues to return the previous center until you set the Center to the same value as the TransformCenter.

During initialization of the Map control, the CenterChanged event is raised one time after the initialization. If your app handles the CenterChanged event, make sure that you handle this event correctly when it’s raised after initialization of the control.

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 by using code.


// Constructor
public MainPage()
{
   InitializeComponent();

   Map MyMap = new Map();
   MyMap.Center = new GeoCoordinate(47.6097, -122.3331);
   ContentPanel.Children.Add(MyMap);
}

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2014 Microsoft. All rights reserved.