Basic Gauge
This sample uses the CommunityToolkit.Mvvm package
and C# 14 partial properties: C# 14 is the default with the .NET 10 SDK, on older target frameworks set
<LangVersion>14</LangVersion>. You can learn more about the samples
here.
View model
namespace ViewModelsSamples.Pies.Gauge1;
public class ViewModel
{
public double Value { get; set; } = 30;
}
XAML
<UserControl
x:Class="WinUISample.Pies.Gauge1.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.Pies.Gauge1"
mc:Ignorable="d"
MaxWidth="300"
MaxHeight="300">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:PieChart
InitialRotation="-90"
MinValue="0"
MaxValue="100">
<lvc:PieChart.Series>
<lvc:SeriesCollection>
<!--
The main gauge series.
-->
<lvc:XamlGaugeSeries
GaugeValue="{Binding Value}"
DataLabelsSize="50"
MaxRadialColumnWidth="50"/>
<!-- The background series is used to style the gauge background. -->
<lvc:XamlGaugeBackgroundSeries/>
</lvc:SeriesCollection>
</lvc:PieChart.Series>
</lvc:PieChart>
</UserControl>
Related articles:
~/samples/pies/gauge1/template.md