Click or drag to resize
MapViewExtentChanged Event
Occurs when map extent changed.

Namespace: Esri.ArcGISRuntime.Controls
Assembly: Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 10.2.7.0 (10.2.7.1234)
Syntax
public event EventHandler ExtentChanged

Value

Type: SystemEventHandler
Examples

Shows how to set the initial extent of the map (Map.InitialViewpoint) in code.

Code example using the Map.ExtentChanged Event.

XAML
<Window x:Class="InitialMapExtentCode.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
        Height="600" Width="800">

    <Grid>
        <StackPanel>

            <!-- Display the MapView.Extent to the user. -->
            <TextBlock Text="Current Map.Extent:" HorizontalAlignment="Center"/>
            <TextBox x:Name="myCoords" Height="25" TextAlignment="Center"/>

            <!-- Add a MapView Control. -->
            <esri:MapView x:Name="MapView1" Height="575">

                <!-- Add a Map. -->
                <esri:Map x:Name="MyMap"  >

                    <!-- Add an ArcGISTiledMapServiceLayer. -->
                    <esri:ArcGISTiledMapServiceLayer 
                        ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
                </esri:Map>
            </esri:MapView>

        </StackPanel>

    </Grid>

</Window>

SPECIAL NOTE: The XAML displayed above comes from a C# project. If you are a VB.NET developer, you will need to modify the text for the x:Class namespace from "InitialMapExtentCode.MainWindow" to be just "MainWindow".

// NOTE: Shows how to set the initial extent of the map (Map.InitialExtent) in code.

namespace InitialMapExtentCode
{
    public partial class MainWindow : System.Windows.Window
    {
        public MainWindow()
        {
            InitializeComponent();

            // Define a SpatialReference using the WKID of 102100 (i.e. Web Mercator). Note that the 
            // SpatialReference.Create is a static/Shared function and hence you do not use the 'new'
            // keyword. 
            Esri.ArcGISRuntime.Geometry.SpatialReference mySpatialReference = null;
            mySpatialReference = Esri.ArcGISRuntime.Geometry.SpatialReference.Create(102100);

            // Create an envelope that has the spatial extent of the Rochester, NY region using the Web Mercator
            // SpatialReference.
            Esri.ArcGISRuntime.Geometry.Envelope myEnvelope = null;
            myEnvelope = new Esri.ArcGISRuntime.Geometry.Envelope(-8669706, 5265422, -8538812, 5361422, mySpatialReference);

            // Set the initial extent of the Map (via InitialViewpoint Property) the to that of our Envelope.
            MapView1.Map.InitialViewpoint = new Esri.ArcGISRuntime.Controls.Viewpoint(myEnvelope);

            // Define an Event Handler to fire each time the Map.Extent changes.
            MapView1.ExtentChanged += myMap_ExtentChanged;

        }

        private void myMap_ExtentChanged(object sender, System.EventArgs e)
        {

            // Display the current Map.Extent back to the user in the application.
            myCoords.Text = MapView1.Extent.ToString();

        }

    }
}
See Also
Supported Platforms
This type is supported on the following ArcGIS Runtime .NET SDK platforms:
Windows Desktop
Windows Phone
Windows Store
Additional Examples
Hyperlink to ExampleDescription
InitialMapExtentCodeShows how to set the initial extent of the map (Map.InitialExtent) in code.