# Getting Started with WPF Legend

This tutorial will walk you through the creation of a sample application that contains **RadLegend**.

* [Adding Telerik Assemblies Using NuGet](https://www.telerik.com/products/wpf/documentation/controls/radlegend/getting-started#adding-telerik-assemblies-using-nuget)
* [Adding Assembly References Manually](https://www.telerik.com/products/wpf/documentation/controls/radlegend/getting-started#adding-assembly-references-manually)
* [Defining RadLegend and Adding Items](https://www.telerik.com/products/wpf/documentation/controls/radlegend/getting-started#defining-radlegend-and-adding-items)
* [Customizing the Legend Items](https://www.telerik.com/products/wpf/documentation/controls/radlegend/getting-started#customizing-the-legend-items)
* [Changing the Items Panel](https://www.telerik.com/products/wpf/documentation/controls/radlegend/getting-started#changing-the-items-panel)

## Adding Telerik Assemblies Using NuGet

To use **RadLegend** when working with NuGet packages, install the `Telerik.Windows.Controls.for.Wpf.Xaml` package. The [package name may vary](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/nuget/available-packages) slightly based on the Telerik dlls set - [Xaml or NoXaml](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/xaml-vs-noxaml)

Read more about NuGet installation in the [Installing UI for WPF from NuGet Package](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/nuget/nuget-installation) article.

> tip With the 2025 Q1 release, the Telerik UI for WPF has a new licensing mechanism. You can learn more about it [here](https://www.telerik.com/products/wpf/documentation/installation/licensing/installing-license-key).

## Adding Assembly References Manually

If you are not using NuGet packages, you can add a reference to the following assemblies:

* **Telerik.Licensing.Runtime**
* **Telerik.Windows.Controls**

You can find the required assemblies for each control from the suite in the [Controls Dependencies](https://www.telerik.com/products/wpf/documentation/common-information/installation-installing-dependencies-wpf) help article.

## Defining RadLegend and Adding Items

The RadLegend control is populated with data via its **Items** collection. The collection is of type **LegendItemCollection** and can be populated only with **LegendItem** objects. By default the Items property is *null*.

**Example 1: Defining RadLegend in XAML**

```XAML
<telerik:RadLegend>
    <telerik:RadLegend.Items>
        <telerik:LegendItemCollection>
            <telerik:LegendItem MarkerFill="#FF55AA33" Title="Legend item 1" />
            <telerik:LegendItem MarkerFill="#FFCC3399" Title="Legend item 2" />
            <telerik:LegendItem MarkerFill="#FF5511BB" Title="Legend item 3" />
        </telerik:LegendItemCollection>
    </telerik:RadLegend.Items>
</telerik:RadLegend>
```

**Example 2: Defining RadLegend in code**

```C#
private void DefineLegendInCode()
{
    RadLegend legend = new RadLegend();
    legend.Items = new LegendItemCollection()
    {
        new LegendItem() { Title = "Legend item 1", MarkerFill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF55AA33")) },
        new LegendItem() { Title = "Legend item 2", MarkerFill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFCC3399")) },
        new LegendItem() { Title = "Legend item 3", MarkerFill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF5511BB")) },
    };
}
```

> caption RadLegend

![WPF RadLegend RadLegend](https://www.telerik.com/products/wpf/documentation/assets/b4e38518ed63f2188abc34ec49b3dbed/radlegend-getting-started-0.png)

## Customizing the Legend Items

The most straightforward way to customize the legend items is to set the properties of the **LegendItem** objects added in the Items collection of the control.

To change the fill of the item's marker set the **MarkerFill** property of the LegendItem object.

To change the text of the items set the **Title** property of the LegendItem object.

To change the geometry of the marker set the **MarkerGeometry** property. Read about this in the [Marker Geometry](https://www.telerik.com/products/wpf/documentation/controls/radlegend/marker-geometry) article.

The control also allows you to fully replace its items' template and define a custom visualization. To do so, set the **ItemTemplate** property of the RadLegend control. Read more about this in the [ItemTemplate](https://www.telerik.com/products/wpf/documentation/controls/radlegend/itemtemplate) article.

## Changing the Items Panel

By default the RadLegend control uses a StackPanel to render its items. To change this you can replace the panel via the **ItemsPanel** property. Read more about this in the [ItemsPanel](https://www.telerik.com/products/wpf/documentation/controls/radlegend/itemspanel) article.

## Telerik UI for WPF Learning Resources

* [Getting Started with Telerik UI for WPF Components](https://www.telerik.com/products/wpf/documentation/getting-started/first-steps-nuget)
* [Telerik UI for WPF Installation](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/installation-guide)
* [Telerik UI for WPF and WinForms Integration](https://www.telerik.com/products/wpf/documentation/common-information/winforms-integration/overview)
* [Telerik UI for WPF Visual Studio Templates](https://www.telerik.com/products/wpf/documentation/installation/manual-setup-guides/visual-studio-templates)
* [Setting a Theme with Telerik UI for WPF](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-setting-a-theme-overview)
* [Telerik UI for WPF Virtual Classroom (Training Courses for Registered Users)](https://learn.telerik.com/learn/course/external/view/elearning/16/telerik-ui-for-wpf)
* [Telerik UI for WPF License Agreement](https://www.telerik.com/purchase/license-agreement/wpf-dlw-s)

## See Also

* [Scrollbar Functionality](https://www.telerik.com/products/wpf/documentation/controls/radlegend/scrollbar-functionality)
* [Supported Controls](https://www.telerik.com/products/wpf/documentation/controls/radlegend/supported-controls)
