C# Class ESRI.ArcGIS.Client.Toolkit.Attribution

The Attribution Control displays Copyright information for Layers that have the IAttribution Interface implemented.

The Attribution Control is a User Interface (UI) control that displays Copyright information in a list of Microsoft ContentPresenter Controls for each Layer in a LayerCollection that has the IAttribution Interface implemented. Layers that have the IAttribution Interface implemented have an additional .AttributionTemplate Property which returns a DataTemplate that allows for the display of the Copyright information in the ContentPresenter. As of version 2.2 of the API, the Copyright information is returned as CopyrightText strings for the various Layers that implement the IAttribution interface.

The Attribution Control can be created at design-time in XAML or dynamically at run-time in the code-behind. The Attribution Control is one of several controls available in the Toolbox for Visual Studio when the ArcGIS API for Silverlight is installed, The Attribution Control is one of several controls available in the Toolbox for Visual Studio when the ArcGIS Runtime SDK for WPF is installed, There are no controls that can be dragged into the XAML design surface from the Toolbox as part of the ArcGIS Runtime SDK for Windows Phone installation. Developers need to type the correct syntax in the XAML to have the controls appear in the visual designer, see the following screen shot:

Example of the Attribution Control on the XAML design surface of a Silverlight application.

Example of the Attribution Control on the XAML design surface of a WPF application.

Example of the Attribution Control on the XAML design surface of a Windows Phone application.

The default appearance of the Attribution Control can be modified using numerous inherited Properties from System.Windows.FrameworkElement, System.Windows.UIElement, and System.Windows.Controls. An example of some of these Properties include: .Height, .Width, .BackGround, .BorderBrush, .BorderThickness, .FontFamily, .FontSize, .FontStretch, .FontStyle, .Foreground, .HorizontalAlignment, .VerticalAlignment, .Margin, .Opacity, .Visibility, etc.

Note: you cannot change the core behavior of the sub-components (i.e. ContentPresenter, etc.) of the Attribution Control using standard Properties or Methods alone. To change the core behavior of the sub-components and their appearance of the Control, developers can modify the Control Template in XAML and the associated code-behind file. The easiest way to modify the UI sub-components is using Microsoft Expression Blend. Then developers can delete/modify existing or add new sub-components in Visual Studio to create a truly customized experience. A general approach to customizing a Control Template is discussed in the ESRI blog entitled: Use control templates to customize the look and feel of ArcGIS controls. A specific code example of modifying the Control Template of the Attribution Control can be found in the Attribution.Layers documentation.

The Attribution Control is comprised of mainly one sub-component, a ContentPresenter, that displays Copyright information for each Layer that has the IAttribution Interface implemented. The implied Binding that occurs in the ControlTemplate Style of the Attribution Control to the ContentPresenter sub-component is to the ESRI.ArcGIS.Client.IAttribution Interface members. The IAttribution Interface adds functionality to Layer objects. These special Layer Types have an .AttributionTemplate Property. The .AttributionTemplate Property is the internal mechanism for constructing the IAttribution object. Only those Layers which have a .AttributionTemplate Property will get listed in the ObservabaleCollection(Of IAttribution) as a result of using the Attribution.Items Property. The following Layers are those that implement the IAttribution Interface and have an .AttributionTemplate Property:

ArcGISDynamicMapServiceLayer ArcGISImageServiceLayer ArcGISTiledMapServiceLayer FeatureLayer TileLayer OpenStreetMapLayer

Note: This also means that you can also use implied Binding in the ControlTemplate Style of the Attribution Control for the various Properties of the special Types of Layers such as: .ID, .Url, .Version, etc.

The Attribution.Items Property returns a Read only ObservableCollection(Of IAttribution) object. While it is true that you can use the various ObservableCollection Propeties such as .Add, .Clear, .Remove, etc. to manipulate the contents of what is in the ObservableCollection it is not recommended. The Attribution.PropertyChanged and Attribution.Refreshed Events do not fire as a result of adding/removing items in the ObservableCollection. Additionally, the Map Control does not update by adding/removing items in the ObservableCollection. The correct programming practice to see automatic updates to the Attributon.Items Collection is to add Layers to the Map Control which is bound to the Attribution.Layers. When Binding the Map.Layers to the Attribution.Layers is done any .Add, .Remove, or change to the LayerCollection will result in update to Attribution.Items.

Both the Attribution.PropertyChanged and Attribution.Refreshed Events fire as a result of the Layers that Implement IAttribution in the LayerCollection being added or removed in the Attribution.Layers Property. Use the Attribution.Refreshed Event if you want to add, delete, or modify the default attribution items given by the framework. Use the Attribution.PropertyChanged Event on property Attribution.Items, if you want to be aware of this change in order to hook up an Event fired by Attribution.Items. Note: The various special Layer types that Implement the IAttribution Interface have Copyright information Properties that are ReadOnly (meaning they can't be changed by the client application) and hence it is impossible force the Attribution.PropertyChanged and Attribution.Refreshed Events to update as a result of trying to modify the Copyright information on the client side.

In order to use the Attribution Control it is mandatory that the Attribution.Layers Property be set to a valid LayerCollection. This can be done via Binding in the XAML or by setting the Attribution.Layers Property in the code-behind file. Typically, the LayerCollection object is obtained from the Layers Property on the Map Control.

In the following XAML example, Binding is used to associate a Map Control named 'Map1' with it’s LayerCollection to the Attribution Control’s Layers Property:
<esri:Attribution Name="Attribution1" Layers="{Binding ElementName=Map1,Path=Layers}" />

The default visual appearance of the Attribution Control is minimal when using drag-and-drop to place the control when using drag-and-drop to place the control on the design surface of a XAML page in Visual Studio; there are graphical selection handles but nothing else to denote the visual appearance of the control. At design-time, it is not until the Attribution.Layers Property is specified that placeholder text values will be populated in the control. At design-time, if no ID value is specified for the Layer the placeholder information displayed in the list of ContentPresenter sub-controls will be of the form: "<Type of Layer> attribution.". Conversely, if there is an ID value specified for the Layer the placeholder information displayed in the list of ContentPresenter sub-controls will be of the form: "<Layer ID> attribution.". See the following screen shot to see how the design-time placeholder text appears in the Attribution Control for the associated XAML:

Example of the visual appearance of the Attribution Control at design-time when the Attribution.Layers Property is bound to the Map.Layers Property.

Example of the visual appearance of the Attribution Control at design-time when the Attribution.Layers Property is bound to the Map.Layers Property.

Example of the visual appearance of the Attribution Control at design-time when the Attribution.Layers Property is bound to the Map.Layers Property.

NOTE: It is not until run-time that the actual Copyright information about a Layer will replace the placeholder text that is shown in the Attribution Control defined at design-time. The following image shows the run-time display of the Map Control and the Attribution Control that corresponds to the previous design-time screen shot where the actual Copyright information about the Layers is displayed.

Example of the visual appearance of the Attribution Control at run-time when the Attribution.Layers Property is bound to the Map.Layers Property.

Note: Setting the Layer.ID Property is typically done in XAML or in code-behind. The Layer.ID is usually not populated in the map service.

If length of the Copyright information string for a Layer exceeds the Attribution Controls Width, the text will wrap across multiple lines to avoid truncation.

Inheritance: System.Windows.Controls.Control, INotifyPropertyChanged
Show file Open project: Esri/arcgis-toolkit-sl-wpf

Public Properties

Property Type Description
LayersProperty System.Windows.DependencyProperty

Public Methods

Method Description
OnApplyTemplate ( ) : void

When overridden in a derived class, is invoked whenever application code or internal processes call M:System.Windows.FrameworkElement.ApplyTemplate.

Private Methods

Method Description
AttachLayerHandler ( Layer layer ) : void
AttachLayersHandler ( LayerCollection layers ) : void
Attribution ( ) : System

Static initialization for the Attribution control.

DetachLayerHandler ( Layer layer ) : void
DetachLayersHandler ( LayerCollection layers ) : void
EnumerateLeafLayers ( IEnumerable layers ) : IEnumerable
Layers_CollectionChanged ( object sender, System e ) : void
Layers_LayersInitialized ( object sender, EventArgs args ) : void
OnLayersPropertyChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnLayersPropertyChanged ( LayerCollection oldLayers, LayerCollection newLayers ) : void
OnPropertyChanged ( string propertyName ) : void
OnRefreshed ( ) : void
UpdateAttributionItems ( ) : void

Updates the attribution items with the layers implementing IAttribution and returning non null AttributionTemplate.

layer_PropertyChanged ( object sender, PropertyChangedEventArgs e ) : void

Method Details

OnApplyTemplate() public method

When overridden in a derived class, is invoked whenever application code or internal processes call M:System.Windows.FrameworkElement.ApplyTemplate.
public OnApplyTemplate ( ) : void
return void

Property Details

LayersProperty public static property

Identifies the Layers dependency property.
public static DependencyProperty,System.Windows LayersProperty
return System.Windows.DependencyProperty