Click or drag to resize
Code Example - InitialMapExtentXaml

Shows how to set the initial extent of the map (Map.InitialExtent) in XAML.

Code Example
Initial Map Extent Xaml

This section contains selected code files from a Visual Studio project that emphasize specific ArcGIS Runtime SDK (Windows Desktop) features. For example: some code examples may accomplish the bulk of the work as a configuration property in the .xaml file and hence only the .xaml file will be shown in detail below. In other code examples, the .xaml is used to define the configuration of graphical elements for the application but the application logic is performed in the code behind, hence you may see both the .xaml and .cs/.vb files shown in detail below.

XAML
<Window x:Class="InitialMapExtentXaml.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">

    <!-- This sample shows how to set the initial extent of the map (Map.InitialExtent) in XAML. -->

    <Grid>

        <!-- Add a MapView Control to the application. -->
        <esri:MapView x:Name="MapView1">

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

                <!-- Set the initial extent (via the InitialViewpoint Property) to the Spokane, Washington/western Idaho region. -->
                <esri:Map.InitialViewpoint>
                    <esri:ViewpointExtent XMin="-13094473" YMin="5988845" XMax="-12963579" YMax="6084845"/>
                </esri:Map.InitialViewpoint>

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

    </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 "InitialMapExtentXaml.MainWindow" to be just "MainWindow".