Show Map Extent Online

This sample includes a Map and a ArcGISTiledMapServiceLayer and demonstrates how to handle extent changing and changed events on the map. Both events share the same event handler in code behind. The extent parameters of the map are displayed in a textblock as they change at runtime. Since the Map is in wrap-around mode, absolute values represent the map extent on an infinite continuous grid where values on the X axis increase or decrease as you pan. Normalized values represent the map extent in the real-world and take the dateline (or current central meridian) into account.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.MapExtent"
    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/client/2009">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                <LinearGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </LinearGradientBrush.RelativeTransform>
                <GradientStop Color="#FF145787" Offset="0.16"/>
                <GradientStop Color="#FF3D7FAC" Offset="0.502"/>
                <GradientStop Color="#FF88C5EF" Offset="0.984"/>
            </LinearGradientBrush>
        </Grid.Resources>

        <esri:Map x:Name="MyMap" WrapAround="True" ExtentChanged="MyMap_ExtentChanged" ExtentChanging="MyMap_ExtentChanged">
            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
                Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
        </esri:Map>

        <Grid  HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" >

            <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray"  RadiusX="10" RadiusY="10" Margin="0,0,0,5">
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
            <StackPanel Orientation="Vertical" Margin="25">
                <StackPanel.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="FontWeight" Value="Bold"/>
                        <Setter Property="FontSize" Value="11" />
                    </Style>
                </StackPanel.Resources>
                <TextBlock Foreground="Black">
          <Run FontStyle="Italic">Absolute</Run>
          <LineBreak />
          <Run>MinX: </Run>
          <Run Text="{Binding ElementName=MyMap, Path=Extent.XMin, StringFormat=\{0:F3\}}" />
          <LineBreak />

          <Run>MinY: </Run>
          <Run Text="{Binding ElementName=MyMap, Path=Extent.YMin, StringFormat=\{0:F3\}}" />
          <LineBreak />

          <Run>MaxX: </Run>
          <Run Text="{Binding ElementName=MyMap, Path=Extent.XMax, StringFormat=\{0:F3\}}" />
          <LineBreak />

          <Run>MaxY: </Run>
          <Run Text="{Binding ElementName=MyMap, Path=Extent.YMax, StringFormat=\{0:F3\}}" />
               
          <LineBreak />
          <LineBreak />
          <Run FontStyle="Italic">Normalized</Run>
          <LineBreak />
          <Run>Left X: </Run>
          <Run x:Name="MinXNormalized" />
          <LineBreak />
          <Run>Bottom Y: </Run>
          <Run x:Name="MinYNormalized"/>
          <LineBreak />
          <Run>Right X: </Run>
          <Run x:Name="MaxXNormalized"/>
          <LineBreak />
          <Run>Top Y: </Run>
          <Run x:Name="MaxYNormalized"/>
                </TextBlock>
            </StackPanel>
        </Grid>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014