Skip to main content
A newer version of this page is available. .

ColorLegendItem Class

An item that stores information about the color and description of the ColorLegendBase class descendants.

Namespace: DevExpress.XtraMap

Assembly: DevExpress.XtraMap.v18.1.dll

Declaration

public class ColorLegendItem :
    MapLegendItemBase

Example

To use images in a legend, do the following.

  1. Assign the image storage to the ColorListLegend.ImageList property.
  2. Add several ColorLegendItem objects with the specified ColorLegendItem.ImageIndex property to the ColorListLegend.CustomItems collection.
    object data = LoadData(xmlFilepath);

    // Create a map and data for it.
    MapControl map = new MapControl() {
        CenterPoint = new GeoPoint(-37.2, 143.2),
        ZoomLevel = 5,
        Dock = DockStyle.Fill,
        ToolTipController = new ToolTipController() { AllowHtmlText = true },
        ImageList = LoadImage(imageFilepath)
    };
    this.Controls.Add(map);
    //Create a Legend containing images.
    ColorListLegend legend = new ColorListLegend();
    legend.ImageList = map.ImageList;
    legend.CustomItems.Add(new ColorLegendItem() { ImageIndex = 0, Text = "Shipwreck" });
    map.Legends.Add(legend);
// Loads an image to an image collection.
private ImageCollection LoadImage(string path) {
    ImageCollection imageCollection = new ImageCollection();
    Bitmap image = new Bitmap(path);
    imageCollection.ImageSize = new Size(50, 50);
    imageCollection.Images.Add(image);
    return imageCollection;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the ColorLegendItem class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

See Also