Custom Legends

There are 2 ways to customize tooltips, styling and templating.

Styling a legend

A chart exposes many properties to quickly style a legend:

<lvc:CartesianChart
    Series="{Binding Series}"
    LegendPosition="Left"
    LegendFontFamily="Courier New"
    LegendFontSize="25"
    LegendTextBrush="#f2f4c3"
    LegendBackground="#480032">
</lvc:CartesianChart>

The code above would result in the following legend:

custom

Templating a legend

If you need to customize more, you can also use the create your own template:

<UserControl
    x:Class="WinUISample.General.TemplatedLegends.View"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:lvc="using:LiveChartsCore.SkiaSharpView.WinUI"
    xmlns:vms="using:ViewModelsSamples.General.TemplatedLegends"
    mc:Ignorable="d">

    <UserControl.DataContext>
        <vms:ViewModel/>
    </UserControl.DataContext>
    <Grid>
        <lvc:CartesianChart Series="{Binding Series}" LegendPosition="Right" >
            <!-- mark -untilCloses CartesianChart.LegendTemplate -->
            <lvc:CartesianChart.LegendTemplate>
                <DataTemplate>
                    <ItemsControl ItemsSource="{Binding SeriesCollection}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel
                                    Background="{Binding Background}"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    Orientation="{Binding Orientation}" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Border Padding="15 4">
                                    <StackPanel Orientation="Horizontal" Background="#F5F5DC">
                                        <TextBlock
                                            Text="{Binding Series.Name}"
                                            FontFamily="{Binding FontFamily}"
                                            Foreground="{Binding Foreground}"
                                            FontSize="{Binding FontSize}"
                                            FontStyle="{Binding FontStyle}"
                                            FontStretch="{Binding FontStretch}"
                                            VerticalAlignment="Center"/>
                                        <lvc:MotionCanvas
                                            Margin="0 0 8 0"
                                            PaintTasks="{Binding Series.CanvasSchedule.PaintSchedules}"
                                            Width="{Binding Series.CanvasSchedule.Width}"
                                            Height="{Binding Series.CanvasSchedule.Height}"
                                            VerticalAlignment="Center"/>
                                    </StackPanel>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </DataTemplate>
            </lvc:CartesianChart.LegendTemplate>
        </lvc:CartesianChart>
    </Grid>

</UserControl>

You can find another example at the source code of the DefaultLegend class (xaml, code).

custom tooltip