Xceed Toolkit Plus for WPF v4.6 Documentation
Legend Class
Members  Example 


Xceed.Wpf.Toolkit Assembly > Xceed.Wpf.Toolkit.Chart Namespace : Legend Class
Represents a chart legend.
Syntax
'Declaration
 
<DefaultEventAttribute("OnItemsChanged")>
<DefaultPropertyAttribute("Items")>
<ContentPropertyAttribute("Items")>
<StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=System.Windows.FrameworkElement)>
<LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)>
<XmlLangPropertyAttribute("Language")>
<UsableDuringInitializationAttribute(True)>
<RuntimeNamePropertyAttribute("Name")>
<UidPropertyAttribute("Uid")>
<TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider)>
<NameScopePropertyAttribute("NameScope", System.Windows.NameScope)>
Public Class Legend 
   Inherits System.Windows.Controls.ItemsControl
'Usage
 
Dim instance As Legend
[DefaultEvent("OnItemsChanged")]
[DefaultProperty("Items")]
[ContentProperty("Items")]
[StyleTypedProperty(Property="ItemContainerStyle", StyleTargetType=System.Windows.FrameworkElement)]
[Localizability(LocalizationCategory.None, Readability=Readability.Unreadable)]
[XmlLangProperty("Language")]
[UsableDuringInitialization(true)]
[RuntimeNameProperty("Name")]
[UidProperty("Uid")]
[TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]
[NameScopeProperty("NameScope", System.Windows.NameScope)]
public class Legend : System.Windows.Controls.ItemsControl 
Remarks

A Chart contains a collection of Area instances that each contain a collection of Series instances. A Legend combines all of the series from all of the areas in one place.

Use the various properties to configure the legend's appearance and behavior.

Example
The following example shows how to set up a legend that displays information related to two Series, each of which is contained in a different Area in the chart. The legend's Dock, AllowResize, AllowDock, AllowMove, and Title propeties are used to specify its appearance and behavior.
<Window x:Class="WpfApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <xctk:Chart >
            <xctk:Chart.Legend>
                <xctk:Legend x:Name="_legend"
                                  Dock="Left"
                                  AllowResize="True"
                                  AllowDock="True"
                                  AllowMove="True"
                                  Title="Legend"/>
            </xctk:Chart.Legend>
            <xctk:Chart.Areas>
                <xctk:Area Title="Wins/month">
                    <xctk:Area.XAxis>
                        <xctk:Axis ShowAxisLabel="False" ShowTickLabels="False" ShowTicks="False"/>
                    </xctk:Area.XAxis>
                    <xctk:Area.YAxis>
                        <xctk:Axis  ShowAxisLabel="False" ShowTickLabels="False" ShowTicks="False"/>
                    </xctk:Area.YAxis>
                    <xctk:Area.Series>
                        <xctk:Series  Title="Months"
                                          DefaultInterior="Green"
                                          ShowPointsInLegend="True"
                                          ShowHintLabels="True">
                            <xctk:Series.Layout>
                                <xctk:PieLayout />
                            </xctk:Series.Layout>
                            <xctk:Series.DataPoints>
                                <xctk:DataPoint X="6" Y="6" Label="Jan" />
                                <xctk:DataPoint X="7" Y="7" Label="Feb"/>
                                <xctk:DataPoint X="4" Y="4" Label="Mar" />
                                <xctk:DataPoint X="2" Y="2" Label="Apr"/>
                            </xctk:Series.DataPoints>
                        </xctk:Series>
                    </xctk:Area.Series>
                </xctk:Area>

                <xctk:Area Title="Goals/player">
                    <xctk:Area.XAxis>
                        <xctk:Axis Title="Player's Name" LabelsType="Labels" GraduationMode="Manual"/>
                    </xctk:Area.XAxis>
                    <xctk:Area.YAxis>
                        <xctk:Axis Title="Goals" AxisLabelsLayout="ShowToFit"/>
                    </xctk:Area.YAxis>
                    <xctk:Area.Series>
                        <xctk:Series  Title="Players"
                                          DefaultInterior="Orange">
                            <xctk:Series.Layout>
                                <xctk:ColumnLayout />
                            </xctk:Series.Layout>
                            <xctk:Series.DataPoints>
                                <xctk:DataPoint Y="36" Label="Tom" />
                                <xctk:DataPoint Y="7" Label="Steven"/>
                                <xctk:DataPoint Y="24" Label="Kirk" />
                                <xctk:DataPoint Y="12" Label="Erik"/>
                                <xctk:DataPoint Y="10" Label="Scott"/>
                            </xctk:Series.DataPoints>
                        </xctk:Series>
                    </xctk:Area.Series>
                </xctk:Area>
            </xctk:Chart.Areas>
        </xctk:Chart>
    </Grid>
</Window>
Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Media.Visual
            System.Windows.UIElement
               System.Windows.FrameworkElement
                  System.Windows.Controls.Control
                     System.Windows.Controls.ItemsControl
                        Xceed.Wpf.Toolkit.Chart.Legend

Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Legend Members
Xceed.Wpf.Toolkit.Chart Namespace