ArcGIS API for Silverlight - Library Reference
AttributionTemplate Property
See Also  Example Send comments on this topic
ESRI.ArcGIS.Client.Toolkit.DataSources Namespace > OpenStreetMapLayer Class : AttributionTemplate Property

Gets the attribution template of the layer.

Syntax

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

Remarks

The AttributionTemplate Property returns a DataTemplate that allows for the display of the credit information of the OpenStreetMapLayer.

The typical use case is to use an Esri Attribution Control is where the Map.Layers Property is bound to the Attribution.Layers Property. This will enable the display of the credit/CopyrightText information about various layers in a nicely formatted output with minimal programming effort. The ease of use for this use case becomes readily apparent when there are multiple layers with credit/CopyrightText information that need to be displayed and only a single binding needs to take place. Note: All layers that have an AttributionTemplate Property have the IAttribution Interface implemented.

The AttributionTemplate is read-only and is only useful to display the credit/CopyrightText information. It is not possible to set the credit/CopyrightText information on the client side nor is it possible to change the internals of the DataTemplate obtained by the AttributionTemplate.

Any Control that has a ContentTemplate Property can display the information contained in the AttributionTemplate. These Controls can have their base Properties modified to alter the appearance of the credit/CopyrightText information being displayed (i.e. FontSize, Foreground, etc.). When multiple layers have credit/CopyrightText information that needs attributed, it takes more complex programming logic to display the information; consider using the ESRI Attribution Control instead.

Whenever an OpenStreetMapLayer is used in a production application based on services from the OpenStreetMap organization, it is required by their license agreement to provide the appropriate credit for using their data. The credit information for maps provided by the OpenStreetMap organization is stored in the OpenStreetMapLayer.AttributionTemplate Property. To display the credit information in your application is most easily accomplished by adding an Esri Attribution control to your client application and binding the Attribution.Layers Property to the OpenStreetMapLayer. The following is an XAML example of how to accomplish this:

            <esri:Map x:Name="MyMap">
              <esri:OpenStreetMapLayer Style="Mapnik" />
            </esri:Map>
            <esri:Attribution Layers="{Binding ElementName=MyMap, Path=Layers}" />
            

OpenStreetMap is released under the Create Commons "Attribution-Share Alike 2.0 Generic" license.

Property Value

The attribution template.

Example

How to use:

Click the 'Display credit information' Button to display credit information in various controls.

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 the OpenStreetMapLayer.AttributeTemplate information in various controls.

XAMLCopy Code
<Grid x:Name="LayoutRoot">
  
  <!-- Add a Map Control. -->
  <esri:Map Background="White" HorizontalAlignment="Left" Margin="0,180,0,0" Name="Map1" 
        VerticalAlignment="Top" Height="300" Width="400" >
    
    <!-- Define an OpenStreetMapLayer. -->
    <esri:OpenStreetMapLayer Style="NoName"/>
    
  </esri:Map>
  
  <!-- 
  Add a Button to display OpenStreetMapLayer credit information. 
  -->
  <Button Content="Display credit information" Height="23" 
          HorizontalAlignment="Left" Margin="12,151,0,0" Width="763" VerticalAlignment="Top" 
          Name="ButtonAttributionTemplate" Click="ButtonAttributionTemplate_Click"/>
  
  <!-- ESRI Attribution Control  -->
  <sdk:Label Height="24" HorizontalAlignment="Left" Margin="410,256,0,0" Name="Label_Attribution" 
       VerticalAlignment="Top" Width="346" Content="ESRI Attribution Control:"/>
  <esri:Attribution HorizontalAlignment="Left" Margin="406,279,0,0" Name="Attribution1" 
        VerticalAlignment="Top" Height="30" Width="350" />
  
  <!-- A ContentControl -->
  <sdk:Label Height="24" HorizontalAlignment="Left" Margin="410,341,0,0" Name="Label_ContentControl" 
       VerticalAlignment="Top" Width="346" Content="Content Control:"/>
  <ContentControl Height="30" HorizontalAlignment="Left" Margin="410,361,0,0" 
                  Name="ContentControl1" VerticalAlignment="Top" Width="346" 
                  FontSize="20" Foreground="Red" />
  
  <!-- A Button -->
  <sdk:Label Height="24" HorizontalAlignment="Left" Margin="410,424,0,0" Name="Label_Button" 
       VerticalAlignment="Top" Width="346" Content="Button:"/>
  <Button Height="30" HorizontalAlignment="Left" Margin="410,448,0,0" 
          Name="Button1" VerticalAlignment="Top" Width="346" />
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="52" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="756" TextWrapping="Wrap" 
             Text="Click the 'Display credit information' Button to display credit information in various controls." />
  
</Grid>
C#Copy Code
private void ButtonAttributionTemplate_Click(object sender, System.Windows.RoutedEventArgs e)
{
  // Get the OpenStreetMapLayer.
  ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer myOpenStreetMapLayer = null;
  myOpenStreetMapLayer = (ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer)(Map1.Layers[0]);
  
  // Display the OpenStreetMapLayer credit information via the ESRI Attribution Control.
  Attribution1.Layers = Map1.Layers;
  
  // Display the OpenStreetMapLayer credit information via a Microsoft ContentControl.
  ContentControl1.ContentTemplate = myOpenStreetMapLayer.AttributionTemplate;
  ContentControl1.Content = myOpenStreetMapLayer;
  
  // Display the OpenStreetMapLayer credit information via a Button.
  Button1.ContentTemplate = myOpenStreetMapLayer.AttributionTemplate;
  Button1.Content = myOpenStreetMapLayer;
}
VB.NETCopy Code
Private Sub ButtonAttributionTemplate_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  
  ' Get the OpenStreetMapLayer.
  Dim myOpenStreetMapLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer
  myOpenStreetMapLayer = CType(Map1.Layers.Item(0), ESRI.ArcGIS.Client.Toolkit.DataSources.OpenStreetMapLayer)
  
  ' Display the OpenStreetMapLayer credit information via the ESRI Attribution Control.
  Attribution1.Layers = Map1.Layers
  
  ' Display the OpenStreetMapLayer credit information via a Microsoft ContentControl.
  ContentControl1.ContentTemplate = myOpenStreetMapLayer.AttributionTemplate
  ContentControl1.Content = myOpenStreetMapLayer
  
  ' Display the OpenStreetMapLayer credit information via a Button.
  Button1.ContentTemplate = myOpenStreetMapLayer.AttributionTemplate
  Button1.Content = myOpenStreetMapLayer
  
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.