Dashed Lines

This sample uses C# 13 preview features such as partial properties, it also uses features from the CommunityToolkit.Mvvm package, you can learn more about it here.

sample image sample image

View Model

namespace ViewModelsSamples.Design.StrokeDashArray;

public class ViewModel
{
    public int[] Values { get; set; } =
        [4, 2, 8, 5, 3];
}

XAML

<UserControl
    x:Class="WinUISample.Design.StrokeDashArray.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.Design.StrokeDashArray"
    mc:Ignorable="d">

    <UserControl.DataContext>
        <vms:ViewModel/>
    </UserControl.DataContext>

    <lvc:CartesianChart>
        <lvc:CartesianChart.Series>
            <lvc:SeriesCollection>
                <lvc:XamlLineSeries
                    Values="{Binding Values}"
                    LineSmoothness="1"
                    GeometrySize="22"
                    
                    Fill="{x:Null}"/>

                <!--
                Nested extensions are not working in Uno
                
                Stroke="{lvc:SolidColorPaint
                    Color='#6495ED',
                    StrokeCap=Round,
                    StrokeWidth=10,
                    PathEffect={lvc:Dashed Array='30, 20'}}"
                -->
            </lvc:SeriesCollection>
        </lvc:CartesianChart.Series>
    </lvc:CartesianChart>
</UserControl>