Implement a Legend Control in Unbound Mode

The RadLegendControl allows a complete customization of the legend items - if you don’t want the content of the legend to be bound to a chart, then you can specify the items explicitly by adding LegendItem items to the LegendItems collection.


The following example demonstrates how to implement a RadLegendControl for a BarSeries in unbound mode:

Legend Control-Unbound Mode

  1. First, create a class that will represent a single DataPoint:

    public class CustomPoint
        public double Value { get; set; }
        public string Category { get; set; }
  2. Then, create a ViewModel class to hold a collection of points:

    public class ViewModel
        public ViewModel()
            this.SeriesData = new List<CustomPoint>()
                new CustomPoint { Category = "Dogs", Value = 10 },
                new CustomPoint { Category = "Cats", Value = 14 },
                new CustomPoint { Category = "Birds", Value = 5 },
        public List<CustomPoint> SeriesData { get; set; }
  3. Create the RadCartesianChart in XAML:

    <telerikChart:RadCartesianChart PaletteName="DefaultDark" Width="200" Height="200">
        <telerikChart:BarSeries ItemsSource="{Binding SeriesData}" PaletteMode="DataPoint">
                <telerikChart:PropertyNameDataPointBinding PropertyName="Category"/>
                <telerikChart:PropertyNameDataPointBinding PropertyName="Value"/>
  4. Finally, create the RadLegendControl using XAML specifying each legend item independently of the chart.

            <telerikPrimitives:LegendItem Fill="#1E98E4" Stroke="#1E98E4" Title="Dogs"/>
            <telerikPrimitives:LegendItem Fill="#FFC500" Stroke="#FFC500" Title="Cats"/>
            <telerikPrimitives:LegendItem Fill="#FF2A00" Stroke="#FF2A00" Title="Birds"/>