Skip to main content
All docs
V24.2

LegendBase.ItemVisibilityMode Property

Specifies how to display custom and automatically generated items in a legend.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v24.2.dll

Declaration

[XtraChartsLocalizableCategory(XtraChartsCategory.Elements)]
public LegendItemVisibilityMode ItemVisibilityMode { get; set; }

Property Value

Type Description
LegendItemVisibilityMode

A LegendItemVisibilityMode enumeration value that specifies the legend’s visibility mode.

Available values:

Name Description
Default

If a legend has custom items, then automatically generated items are not displayed.

AutoGeneratedAndCustom

The legend displays custom and automatically generated items together.

Example

This example demonstrates how to add a custom legend item to a legend.

View Example

Custom Legend Item

Create a CustomLegendItem object and add it to the CustomItems collection. Use the following properties to configure the custom item:

CustomLegendItem.MarkerImage
Returns the custom legend item’s marker image.
CustomLegendItem.Text
Gets or sets the text the custom legend item displays.

To show custom and automatically generated legend items, set the LegendBase.ItemVisibilityMode to AutoGeneratedAndCustom.

using DevExpress.Drawing;
using DevExpress.XtraCharts;
using System;
using System.IO;
using System.Windows.Forms;

namespace CustomLegendItemSample {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {
            #region #CustomLegendItems
            // Create a new custom item.
            CustomLegendItem item = new CustomLegendItem();
            chart.Legend.CustomItems.Add(item);
            // Specify its text and marker.
            item.Text = "Custom Legend Item";
            FileStream outfile = new FileStream("Image\\DXLogo_16x16.png", FileMode.Open);
            DXImage image = DXImage.FromStream(outfile);
            item.MarkerImage.DXImage = image;

            // Set a value indicating that both autogenerated and custom items are displayed.
            chart.Legend.ItemVisibilityMode = LegendItemVisibilityMode.AutoGeneratedAndCustom;
            #endregion #CustomLegendItems
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ItemVisibilityMode property.

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.

See Also