ArcGIS Runtime SDK for .NET Samples

Map reference scale

Set a map reference scale

Loading

Code

<UserControl x:Class="ArcGISRuntime.WPF.Samples.MapReferenceScale.MapReferenceScale"
             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">
    <Grid>
        <esri: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}"
                          Margin="0,5,0,5">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock>
                                <!-- Runs are used to format a plain double to match the convention for writing map scales. -->
                                <Run Text="1:" />
                                <Run Text="{Binding Path=.,StringFormat=n0}" />
                            </TextBlock>
                        </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">
                    <ListView.ItemTemplate>
                        <DataTemplate DataType="esri: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}" />
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                <TextBlock>
                    <!-- A run is used to format the label. -->
                    <Run Text="Current map scale: " />
                    <Run Text="1:" />
                    <Run Text="{Binding ElementName=MyMapView,Path=MapScale,Mode=OneWay,StringFormat=n0}" />
                </TextBlock>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>


In this topic
  1. Code