Click or drag to resize
Code Example - FeatureServiceLayerInfo_CopyrightText

Demonstrates using the GetDetailsAsync Method to obtain the FeatureServiceLayerInfo.CopyrightText on an ArcGISDynamicMapServiceLayer.

Code Example
Feature Service Layer Info Copyright Text

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="FeatureServiceLayerInfo_CopyrightText.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"
    Title="MainWindow" Height="600" Width="800">

    <Grid x:Name="LayoutRoot">

        <!-- Add a MapView Control. -->
        <esri:MapView x:Name="MapView1" Background="White" HorizontalAlignment="Left" Margin="10,155,0,0"
                      VerticalAlignment="Top" Height="405" Width="772" >

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

                <!-- Define an ArcGISDynamicMapServiceLayer. -->
                <esri:ArcGISDynamicMapServiceLayer ImageFormat="PNG24"
                     ServiceUri="http://sampleserver1.arcgisonline.com:80/arcgis/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/>

            </esri:Map>
        </esri:MapView>

        <!-- Display the CopyrightText information (the Property is Read Only). -->
        <Label Height="24" HorizontalAlignment="Left" Margin="0,52,0,0" Name="Label_CopyrightText" 
               VerticalAlignment="Top" Width="782" Content="CopyrightText:"/>
        <TextBox Height="69" HorizontalAlignment="Left" Margin="10,81,0,0" Name="TextBox_CopyrightText" 
                 VerticalAlignment="Top" Width="772" TextWrapping="Wrap" />

        <!-- Add a TextBlock to hold the instructions on how to use the sample code. -->
        <TextBlock Height="52" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="772" 
                   TextWrapping="Wrap" Margin="10,0,0,0" />

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

namespace FeatureServiceLayerInfo_CopyrightText
{
    public partial class MainWindow : System.Windows.Window
    {
        public MainWindow()
        {
            // This call is required by the designer.
            InitializeComponent();

            // Add any initialization after the InitializeComponent() call.

            // Add the instructions on how to use this example code to the TextBlock.
            TextBlock1.Text = "When the application loads, the ArcGISDynamicMapServiceLayer's CopyrightText " + 
                "will be automatically populated in the TextBlock.";

            // Set the initial extent using the InitialViewpoint Property to the Iowa area.
            Esri.ArcGISRuntime.Geometry.Envelope myEnvelope = new Esri.ArcGISRuntime.Geometry.Envelope(-96.89, 39.47, -89.91, 44.7);
            MapView1.Map.InitialViewpoint = new Esri.ArcGISRuntime.Controls.Viewpoint(myEnvelope);

            // Get the ArcGISDynamicMapServiceLayer from the Map that was set in XAML.
            Esri.ArcGISRuntime.Layers.LayerCollection myLayerCollection = MapView1.Map.Layers;
            Esri.ArcGISRuntime.Layers.Layer myLayer = myLayerCollection[0];
            Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer = (Esri.ArcGISRuntime.Layers.ArcGISDynamicMapServiceLayer)myLayer;

            // Get the details for the first (i.e. 0) sub-layer. 
            System.Threading.Tasks.Task<Esri.ArcGISRuntime.ArcGISServices.FeatureServiceLayerInfo> myTask = myArcGISDynamicMapServiceLayer.GetDetailsAsync(0);

            // CopyrightText (This Property is Read Only).
            // NOTE: The CopyrightText information is set in the Credits section on the General tab of the Data Frame 
            // Properties dialog in ArcMap.
            Esri.ArcGISRuntime.ArcGISServices.FeatureServiceLayerInfo myFeatureServiceLayerInfo = myTask.Result;
            TextBox_CopyrightText.Text = myFeatureServiceLayerInfo.CopyrightText;
        }
    }
}