.NET Maui Quickstart

Step 1: Create a new .NET MAUI App

Step 2: Install the ScottPlot.Maui NuGet package.

Step 3: Edit MauiProgram.cs to UseScottPlot() at startup:

builder
    .UseMauiApp<App>()
    .UseScottPlot() // ADD THIS LINE
        ...

Step 4: Edit MainPage.xaml to include xmlns:ScottPlot and add a MauiPlot control:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:ScottPlot="clr-namespace:ScottPlot.Maui;assembly=ScottPlot.Maui"
             x:Class="MauiApp5.MainPage">
    <ScottPlot:MauiPlot x:Name="MauiPlot1" />
</ContentPage>

Step 5: Edit MainPage.xaml.cs to setup the plot in the start-up sequence

public MainPage()
{
    InitializeComponent();

    double[] dataX = { 1, 2, 3, 4, 5 };
    double[] dataY = { 1, 4, 9, 16, 25 };
    MauiPlot1.Plot.Add.Scatter(dataX, dataY);

    MauiPlot1.Refresh();
}

Notes for Mobile

High resolution displays may benefit from increasing the scale factor:

MauiPlot1.Plot.ScaleFactor = 3;

Notes for Windows Desktop

Builds targeting Windows Desktop on .NET 8 may require WindowsSdkPackageVersion to be defined (read more)

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<WindowsSdkPackageVersion>10.0.19041.34</WindowsSdkPackageVersion>
                ...

A .NET Maui targeting Windows Desktop app may be launched from the command line like this:

dotnet run -f net8.0-windows10.0.19041.0 -p:WindowsPackageType=None
Morty Proxy This is a proxified and sanitized view of the page, visit original site.