ArcGIS API for Silverlight - Library Reference
LayerInfo Property
See Also  Example Send comments on this topic
ESRI.ArcGIS.Client Namespace > FeatureLayer Class : LayerInfo Property

Gets detailed information (via the FeatureLayerInfo object) about the FeatureLayer.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property LayerInfo As FeatureLayerInfo
C# 
public FeatureLayerInfo LayerInfo {get;}

Remarks

Obtaining information (i.e. get/Read) for the various Properties of a FeatureLayer should occur in the FeatureLayer.Initialized Event or any time after the Initialized Event occurs. This ensures that information retrieved about the FeatureLayer has been obtained after a complete round trip from ArcGIS Server. Do not be tempted to try and access FeatureLayer Property information from generic application Events like: MainPage.Loaded or the Constructor, etc. as the FeatureLayer has not been Initialized and erroneous information will be returned. Likewise, FeatureLayer Methods should not be invoked until after the FeatureLayer Initialized Event has fired or from within the Initialized Event to avoid erroneous results.

Adding a FeatureLayer to the Map.Layers collection causes the FeatureLayer.Initialized Event to fire.

If you want to obtain FeatureLayerInfo information about a FeatureLayer before adding it to the Map, consider calling the FeatureLayer.Initialize Method which will invoke the FeatureLayerInitialized Event.

Example

How to use:

Click the Button to add a FeatureLayer to the Map. Information about the FeatureLayer via the .LayerInfo Property will be displayed in the TextBox.

The XAML code in this example is used in conjunction with the code-behind (C# or VB.NET) to demonstrate the functionality.

The following screen shot corresponds to the code example in this page.

Displaying FeatureLayer.LayerInfo information.

XAMLCopy Code
<Grid x:Name="LayoutRoot" >
  
  <!-- Add a Map Control to the application. Set the Extent to Mississippi. -->
  <esri:Map x:Name="Map1" WrapAround="True" HorizontalAlignment="Left" Margin="0,303,0,47" Width="297" 
        Extent="-10225304,3446485,-9799179,4197276"/>
  
  <!-- Add a Button that will allow the user to add a FeatureLayer via code-behind. -->
  <Button Content="Add a FeatureLayer and display its LayerInfo" Height="190" HorizontalAlignment="Left" Margin="0,107,0,0" Name="Button_AddFeatureLayer" 
          VerticalAlignment="Top" Width="297" Click="Button_AddFeatureLayer_Click"/>
  
  <!-- TextBox to display information about about the FeatureLayers added to the Map. -->
  <TextBox Height="646" HorizontalAlignment="Left" Margin="303,107,0,0" Name="TextBox1" VerticalAlignment="Top" 
           Width="485" />
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="72" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="788" 
             TextWrapping="Wrap" Text="Click the Button to add a FeatureLayer to the Map. Information about the 
             FeatureLayer via the .LayerInfo Property will be displayed in the TextBox." />
      
</Grid>
C#Copy Code
private void Button_AddFeatureLayer_Click(object sender, System.Windows.RoutedEventArgs e)
{
  // This function executes as a result of the user clicking the Button. It adds an FeatureLayer
  // using code-behind.
  
  // Create an FeatureLayer. The Map1 object (a Map class) was previously defined in XAML.
  ESRI.ArcGIS.Client.FeatureLayer myFeatureLayer = new ESRI.ArcGIS.Client.FeatureLayer();
  
  // Set the Url of the FeatureLayer to a public service. 
  myFeatureLayer.Url = "http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Unemployment_Rate/MapServer/4";
  
  // The Where clause is optional. It is necessary when more that 500/1000 records returned. In ArcGIS Server 
  // 9.3.1 and prior, the default maximum is 500 records returned per FeatureLayer. In ArcGIS Server 10 the 
  // default is 1000. This setting is configurable per map service using ArcCatalog or ArcGIS Server Manager 
  // (on the Parameters tab). In this example we use the Where clause to only return 1 feature.
  myFeatureLayer.Where = "ST_ABBREV = 'MS'";
  
  // Setting the IgnoreServiceScaleRange = True is helpful if the defined map service has restrictions on
  // different scale levels for which the features can be viewed (ex: in the ArcGIS Services Directory REST 
  // documentation these would be the 'Min. Scale' and 'Max. Scale' metadata items). The value of 
  // True always draws the features regardless of the current map scale.
  myFeatureLayer.IgnoreServiceScaleRange = true;
  
  // Set the ID of the FeatureLayer.
  myFeatureLayer.ID = "MS_Unemployment_Rate";
  
  // Wire-up the Initialized Event of the FeatureLayer. 
  myFeatureLayer.Initialized += FeatureLayer_Initialized;
  
  // Add the FeatureLayer to the Map. This will cause the FeatureLayer.Initialized Event to fire.
  Map1.Layers.Add(myFeatureLayer);
}
            
private void FeatureLayer_Initialized(object sender, EventArgs e)
{
  // This function will execute as a result of the FeatureLayer that was defined in code-behind
  // being Initialized.
  
  // Get the FeatureLayer.
  ESRI.ArcGIS.Client.FeatureLayer myFeatureLayer = (ESRI.ArcGIS.Client.FeatureLayer)sender;
  
  // Get the ID of the FeatureLayer.
  string myID2 = myFeatureLayer.ID;
  
  // Get the FeatureLayerInfo object as a result of the FeatureLayer.LayerInfo Property. 
  // It that contains lots of valuable information about the FeatureLayer.
  ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo myFeatureLayerInfo = myFeatureLayer.LayerInfo;
  
  // Create a StringBuilder object to hold information about the FeatureLayer and add the information to it.
  System.Text.StringBuilder myStringBuilder = new System.Text.StringBuilder();
  myStringBuilder.Append("The FeatureLayer.LayerInfo Results for: " + myID2 + Environment.NewLine);
  myStringBuilder.Append("============================================================" + Environment.NewLine);
  myStringBuilder.Append("AllowGeometryUpdates: " + myFeatureLayerInfo.AllowGeometryUpdates.ToString() + Environment.NewLine);
  myStringBuilder.Append("CanModifyLayer: " + myFeatureLayerInfo.CanModifyLayer.ToString() + Environment.NewLine);
  myStringBuilder.Append("CanScaleSymbols: " + myFeatureLayerInfo.CanScaleSymbols.ToString() + Environment.NewLine);
  myStringBuilder.Append("Capabilities.Count: " + myFeatureLayerInfo.Capabilities.Count().ToString() + Environment.NewLine);
  myStringBuilder.Append("CopyrightText: " + myFeatureLayerInfo.CopyrightText + Environment.NewLine);
  myStringBuilder.Append("DefaultSpatialReference.WKID: " + myFeatureLayerInfo.DefaultSpatialReference.WKID.ToString() + Environment.NewLine);
  myStringBuilder.Append("DefinitionExpression: " + myFeatureLayerInfo.DefinitionExpression + Environment.NewLine);
  myStringBuilder.Append("Description: " + myFeatureLayerInfo.Description + Environment.NewLine);
  myStringBuilder.Append("DisplayField: " + myFeatureLayerInfo.DisplayField + Environment.NewLine);
  if (myFeatureLayerInfo.EditFieldsInfo != null)
  {
    myStringBuilder.Append("EditFieldsInfo.EditorField: " + myFeatureLayerInfo.EditFieldsInfo.EditorField + Environment.NewLine);
  }
  myStringBuilder.Append("EnableZDefaults: " + myFeatureLayerInfo.EnableZDefaults.ToString() + Environment.NewLine);
  myStringBuilder.Append("Extent: " + myFeatureLayerInfo.Extent.ToString() + Environment.NewLine);
  if (myFeatureLayerInfo.FeatureTypes != null)
  {
    myStringBuilder.Append("FeatureTypes.Count: " + myFeatureLayerInfo.FeatureTypes.Count.ToString() + Environment.NewLine);
  }
  myStringBuilder.Append("Fields.Count: " + myFeatureLayerInfo.Fields.Count.ToString() + Environment.NewLine);
  myStringBuilder.Append("GeometryType: " + myFeatureLayerInfo.GeometryType.ToString() + Environment.NewLine);
  myStringBuilder.Append("GlobalIdField: " + myFeatureLayerInfo.GlobalIdField + Environment.NewLine);
  myStringBuilder.Append("HasAttachments: " + myFeatureLayerInfo.HasAttachments.ToString() + Environment.NewLine);
  myStringBuilder.Append("HasLabels: " + myFeatureLayerInfo.HasLabels.ToString() + Environment.NewLine);
  myStringBuilder.Append("HasM: " + myFeatureLayerInfo.HasM.ToString() + Environment.NewLine);
  myStringBuilder.Append("HasZ: " + myFeatureLayerInfo.HasZ.ToString() + Environment.NewLine);
  myStringBuilder.Append("Id: " + myFeatureLayerInfo.Id.ToString() + Environment.NewLine);
  myStringBuilder.Append("IsAddAllowed: " + myFeatureLayerInfo.IsAddAllowed.ToString() + Environment.NewLine);
  myStringBuilder.Append("IsDataVersioned:" + myFeatureLayerInfo.IsDataVersioned.ToString() + Environment.NewLine);
  myStringBuilder.Append("IsDeleteAllowed: " + myFeatureLayerInfo.IsDeleteAllowed.ToString() + Environment.NewLine);
  myStringBuilder.Append("IsReadOnly: " + myFeatureLayerInfo.IsReadOnly.ToString() + Environment.NewLine);
  myStringBuilder.Append("IsUpdateAllowed: " + myFeatureLayerInfo.IsUpdateAllowed.ToString() + Environment.NewLine);
  myStringBuilder.Append("MaximumScale: " + myFeatureLayerInfo.MaximumScale.ToString() + Environment.NewLine);
  myStringBuilder.Append("MaxRecordCount: " + myFeatureLayerInfo.MaxRecordCount.ToString() + Environment.NewLine);
  myStringBuilder.Append("MinimumScale: " + myFeatureLayerInfo.MinimumScale.ToString() + Environment.NewLine);
  myStringBuilder.Append("Name: " + myFeatureLayerInfo.Name + Environment.NewLine);
  myStringBuilder.Append("ObjectIdField: " + myFeatureLayerInfo.ObjectIdField + Environment.NewLine);
  if (myFeatureLayerInfo.OwnershipBasedAccessControl != null)
  {
    myStringBuilder.Append("OwnershipBasedAccessControl.AllowOthersToUpdate: " + myFeatureLayerInfo.OwnershipBasedAccessControl.AllowOthersToUpdate + Environment.NewLine);
  }
  myStringBuilder.Append("Relationships: " + myFeatureLayerInfo.Relationships.Count().ToString() + Environment.NewLine);
  myStringBuilder.Append("Renderer.GetType: " + myFeatureLayerInfo.Renderer.GetType().ToString() + Environment.NewLine);
  myStringBuilder.Append("SupportsAdvancedQueries: " + myFeatureLayerInfo.SupportsAdvancedQueries.ToString() + Environment.NewLine);
  myStringBuilder.Append("SupportsStatistics: " + myFeatureLayerInfo.SupportsStatistics.ToString() + Environment.NewLine);
  if (myFeatureLayerInfo.Templates != null)
  {
    myStringBuilder.Append("Templates: " + myFeatureLayerInfo.Templates.Count.ToString() + Environment.NewLine);
  }
  myStringBuilder.Append("Type: " + myFeatureLayerInfo.Type + Environment.NewLine);
  myStringBuilder.Append("TypeIdField: " + myFeatureLayerInfo.TypeIdField + Environment.NewLine);
  myStringBuilder.Append("ZDefault: " + myFeatureLayerInfo.ZDefault.ToString() + Environment.NewLine);
  
  // Display the results of the StringBuilder text to the user.
  TextBox1.Text = myStringBuilder.ToString();
}
VB.NETCopy Code
Private Sub Button_AddFeatureLayer_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
            
  ' This function executes as a result of the user clicking the Button. It adds an FeatureLayer
  ' using code-behind.
  
  ' Create an FeatureLayer. The Map1 object (a Map class) was previously defined in XAML.
  Dim myFeatureLayer As New ESRI.ArcGIS.Client.FeatureLayer
  
  ' Set the Url of the FeatureLayer to a public service. 
  myFeatureLayer.Url = "http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Unemployment_Rate/MapServer/4"
  
  ' The Where clause is optional. It is necessary when more that 500/1000 records returned. In ArcGIS Server 
  ' 9.3.1 and prior, the default maximum is 500 records returned per FeatureLayer. In ArcGIS Server 10 the 
  ' default is 1000. This setting is configurable per map service using ArcCatalog or ArcGIS Server Manager 
  ' (on the Parameters tab). In this example we use the Where clause to only return 1 feature.
  myFeatureLayer.Where = "ST_ABBREV = 'MS'"
  
  ' Setting the IgnoreServiceScaleRange = True is helpful if the defined map service has restrictions on
  ' different scale levels for which the features can be viewed (ex: in the ArcGIS Services Directory REST 
  ' documentation these would be the 'Min. Scale' and 'Max. Scale' metadata items). The value of 
  ' True always draws the features regardless of the current map scale.
  myFeatureLayer.IgnoreServiceScaleRange = True
  
  ' Set the ID of the FeatureLayer.
  myFeatureLayer.ID = "MS_Unemployment_Rate"
  
  ' Wire-up the Initialized Event of the FeatureLayer. 
  AddHandler myFeatureLayer.Initialized, AddressOf FeatureLayer_Initialized
  
  ' Add the FeatureLayer to the Map. This will cause the FeatureLayer.Initialized Event to fire.
  Map1.Layers.Add(myFeatureLayer)
  
End Sub
            
Private Sub FeatureLayer_Initialized(sender As Object, e As EventArgs)
  
  ' This function will execute as a result of the FeatureLayer that was defined in code-behind
  ' being Initialized.
  
  ' Get the FeatureLayer.
  Dim myFeatureLayer As ESRI.ArcGIS.Client.FeatureLayer = CType(sender, ESRI.ArcGIS.Client.FeatureLayer)
  
  ' Get the ID of the FeatureLayer.
  Dim myID2 As String = myFeatureLayer.ID
  
  ' Get the FeatureLayerInfo object as a result of the FeatureLayer.LayerInfo Property. 
  ' It that contains lots of valuable information about the FeatureLayer.
  Dim myFeatureLayerInfo As ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo = myFeatureLayer.LayerInfo
  
  ' Create a StringBuilder object to hold information about the FeatureLayer and add the information to it.
  Dim myStringBuilder As New System.Text.StringBuilder
  myStringBuilder.Append("The FeatureLayer.LayerInfo Results for: " + myID2 + vbCrLf)
  myStringBuilder.Append("============================================================" + vbCrLf)
  myStringBuilder.Append("AllowGeometryUpdates: " + myFeatureLayerInfo.AllowGeometryUpdates.ToString + vbCrLf)
  myStringBuilder.Append("CanModifyLayer: " + myFeatureLayerInfo.CanModifyLayer.ToString + vbCrLf)
  myStringBuilder.Append("CanScaleSymbols: " + myFeatureLayerInfo.CanScaleSymbols.ToString + vbCrLf)
  myStringBuilder.Append("Capabilities.Count: " + myFeatureLayerInfo.Capabilities.Count.ToString + vbCrLf)
  myStringBuilder.Append("CopyrightText: " + myFeatureLayerInfo.CopyrightText + vbCrLf)
  myStringBuilder.Append("DefaultSpatialReference.WKID: " + myFeatureLayerInfo.DefaultSpatialReference.WKID.ToString + vbCrLf)
  myStringBuilder.Append("DefinitionExpression: " + myFeatureLayerInfo.DefinitionExpression + vbCrLf)
  myStringBuilder.Append("Description: " + myFeatureLayerInfo.Description + vbCrLf)
  myStringBuilder.Append("DisplayField: " + myFeatureLayerInfo.DisplayField + vbCrLf)
  If myFeatureLayerInfo.EditFieldsInfo IsNot Nothing Then
    myStringBuilder.Append("EditFieldsInfo.EditorField: " + myFeatureLayerInfo.EditFieldsInfo.EditorField + vbCrLf)
  End If
  myStringBuilder.Append("EnableZDefaults: " + myFeatureLayerInfo.EnableZDefaults.ToString + vbCrLf)
  myStringBuilder.Append("Extent: " + myFeatureLayerInfo.Extent.ToString + vbCrLf)
  If myFeatureLayerInfo.FeatureTypes IsNot Nothing Then
    myStringBuilder.Append("FeatureTypes.Count: " + myFeatureLayerInfo.FeatureTypes.Count.ToString + vbCrLf)
  End If
  myStringBuilder.Append("Fields.Count: " + myFeatureLayerInfo.Fields.Count.ToString + vbCrLf)
  myStringBuilder.Append("GeometryType: " + myFeatureLayerInfo.GeometryType.ToString + vbCrLf)
  myStringBuilder.Append("GlobalIdField: " + myFeatureLayerInfo.GlobalIdField + vbCrLf)
  myStringBuilder.Append("HasAttachments: " + myFeatureLayerInfo.HasAttachments.ToString + vbCrLf)
  myStringBuilder.Append("HasLabels: " + myFeatureLayerInfo.HasLabels.ToString + vbCrLf)
  myStringBuilder.Append("HasM: " + myFeatureLayerInfo.HasM.ToString + vbCrLf)
  myStringBuilder.Append("HasZ: " + myFeatureLayerInfo.HasZ.ToString + vbCrLf)
  myStringBuilder.Append("Id: " + myFeatureLayerInfo.Id.ToString + vbCrLf)
  myStringBuilder.Append("IsAddAllowed: " + myFeatureLayerInfo.IsAddAllowed.ToString + vbCrLf)
  myStringBuilder.Append("IsDataVersioned:" + myFeatureLayerInfo.IsDataVersioned.ToString + vbCrLf)
  myStringBuilder.Append("IsDeleteAllowed: " + myFeatureLayerInfo.IsDeleteAllowed.ToString + vbCrLf)
  myStringBuilder.Append("IsReadOnly: " + myFeatureLayerInfo.IsReadOnly.ToString + vbCrLf)
  myStringBuilder.Append("IsUpdateAllowed: " + myFeatureLayerInfo.IsUpdateAllowed.ToString + vbCrLf)
  myStringBuilder.Append("MaximumScale: " + myFeatureLayerInfo.MaximumScale.ToString + vbCrLf)
  myStringBuilder.Append("MaxRecordCount: " + myFeatureLayerInfo.MaxRecordCount.ToString + vbCrLf)
  myStringBuilder.Append("MinimumScale: " + myFeatureLayerInfo.MinimumScale.ToString + vbCrLf)
  myStringBuilder.Append("Name: " + myFeatureLayerInfo.Name + vbCrLf)
  myStringBuilder.Append("ObjectIdField: " + myFeatureLayerInfo.ObjectIdField + vbCrLf)
  If myFeatureLayerInfo.OwnershipBasedAccessControl IsNot Nothing Then
    myStringBuilder.Append("OwnershipBasedAccessControl.AllowOthersToUpdate: " + myFeatureLayerInfo.OwnershipBasedAccessControl.AllowOthersToUpdate + vbCrLf)
  End If
  myStringBuilder.Append("Relationships: " + myFeatureLayerInfo.Relationships.Count.ToString + vbCrLf)
  myStringBuilder.Append("Renderer.GetType: " + myFeatureLayerInfo.Renderer.GetType.ToString + vbCrLf)
  myStringBuilder.Append("SupportsAdvancedQueries: " + myFeatureLayerInfo.SupportsAdvancedQueries.ToString + vbCrLf)
  myStringBuilder.Append("SupportsStatistics: " + myFeatureLayerInfo.SupportsStatistics.ToString + vbCrLf)
  If myFeatureLayerInfo.Templates IsNot Nothing Then
    myStringBuilder.Append("Templates: " + myFeatureLayerInfo.Templates.Count.ToString + vbCrLf)
  End If
  myStringBuilder.Append("Type: " + myFeatureLayerInfo.Type + vbCrLf)
  myStringBuilder.Append("TypeIdField: " + myFeatureLayerInfo.TypeIdField + vbCrLf)
  myStringBuilder.Append("ZDefault: " + myFeatureLayerInfo.ZDefault.ToString + vbCrLf)
  
  ' Display the results of the StringBuilder text to the user.
  TextBox1.Text = myStringBuilder.ToString
  
End Sub

Requirements

Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7

See Also

© ESRI, Inc. All Rights Reserved.