Skip To Content ArcGIS for Developers Sign In Dashboard

Map reference scale

Set a map reference scale

Loading

<UserControl
    x:Class="ArcGISRuntime.UWP.Samples.MapReferenceScale.MapReferenceScale"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls"
    xmlns:mapping="using:Esri.ArcGISRuntime.Mapping"
    xmlns:converters="using:ArcGISRuntime.Converters">
    <UserControl.Resources>
        <converters:DoubleToScaleStringConverter x:Key="DoubleToScaleStringConverter" />
    </UserControl.Resources>
    <Grid>
        <esriUI:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <StackPanel>
                <TextBlock Text="Choose a map reference scale:"
                           FontWeight="SemiBold" />
                <!-- When the user's selection changes, the SelectedItem binding will apply the value to the Map's ReferenceScale property. -->
                <ComboBox x:Name="ReferenceScaleBox"
                          SelectedItem="{Binding ElementName=MyMapView, Path=Map.ReferenceScale, Mode=TwoWay}"
                          HorizontalAlignment="Stretch"
                          Margin="0,5,0,5">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <!-- The value converter converts from a double to a string that looks like a map scale. -->
                            <TextBlock Text="{Binding Converter={StaticResource DoubleToScaleStringConverter}}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <TextBlock Text="Choose layers to apply scale to:"
                           FontWeight="SemiBold" />
                <!-- Binding is used to display the operational layers for the map view's map, no code behind needed. -->
                <ListView ItemsSource="{Binding ElementName=MyMapView,Path=Map.OperationalLayers}"
                          Margin="0,5,0,5"
                          SelectionMode="None">
                    <ListView.ItemTemplate>
                        <DataTemplate x:DataType="mapping:FeatureLayer">
                            <!-- When the user interacts with the checkbox, 
                                 the two-way binding will update the ScaleSymbols (bool) property automatically. -->
                            <CheckBox Content="{Binding Name}" IsChecked="{Binding ScaleSymbols, Mode=TwoWay}" />
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                <TextBlock>
                    <Run Text="Current map scale: " />
                    <Run
                        Text="{Binding ElementName=MyMapView,Path=MapScale,Mode=OneWay,Converter={StaticResource DoubleToScaleStringConverter}}" />
                </TextBlock>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>

In this topic
  1. Code