Getting Started with .NET MAUI SignaturePad

This section guides you through setting up and configuring a SignaturePad in your .NET MAUI application. Follow the steps below to add a basic SignaturePad to your project.

To quickly get started with the .NET MAUI SignaturePad, watch this video.

Prerequisites

Before proceeding, ensure the following are in place:

  1. Install .NET 8 SDK or later.
  2. Set up a .NET MAUI environment with Visual Studio 2022 (v17.8 or later).

Step 1: Create a New .NET MAUI Project

  1. Go to File > New > Project and choose the .NET MAUI App template.
  2. Name the project and choose a location. Then, click Next.
  3. Select the .NET framework version and click Create.

Step 2: Install the Syncfusion® MAUI SignaturePad NuGet Package

  1. In Solution Explorer, right-click the project and choose Manage NuGet Packages.
  2. Search for Syncfusion.Maui.SignaturePad and install the latest version.
  3. Ensure the necessary dependencies are installed correctly, and the project is restored.

Step 3: Register the handler

Syncfusion.Maui.Core nuget is a dependent package for all Syncfusion® controls of .NET MAUI. In the MauiProgram.cs file, register the handler for Syncfusion® core.

  • C#
  • using Syncfusion.Maui.Core.Hosting;
    
    namespace SignaturePadGettingStarted
    {
        public static class MauiProgram
        {
            public static MauiApp CreateMauiApp()
            {
                var builder = MauiApp.CreateBuilder();
                builder
                .UseMauiApp<App>()
                .ConfigureSyncfusionCore()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                });
    
                return builder.Build();
            }
        }
    }

    Step 4: Add a Basic SignaturePad

    Import the SfSignaturePad namespace and initialize the SignaturePad as shown below.

    <ContentPage
        . . .
        xmlns:signaturePad="clr-namespace:Syncfusion.Maui.SignaturePad;assembly=Syncfusion.Maui.SignaturePad">
        <Grid>
            <signaturePad:SfSignaturePad />
        </Grid>
    </ContentPage>
    using Syncfusion.Maui.SignaturePad;
    
    namespace SignaturePadGettingStarted
    {
        public partial class MainPage : ContentPage
        {
            public MainPage()
            {
                InitializeComponent();
                // Creating a SignaturePad control.
                SfSignaturePad signaturePad = new SfSignaturePad();
                this.content = signaturePad;
            }
        }
    }

    Prerequisites

    Before proceeding, ensure the following are set up:

    1. Install .NET 8 SDK or later is installed.
    2. Set up a .NET MAUI environment with Visual Studio Code.
    3. Ensure that the .NET MAUI extension is installed and configured as described here.

    Step 1: Create a New .NET MAUI Project

    1. Open the Command Palette by pressing Ctrl+Shift+P and type .NET:New Project and press Enter.
    2. Choose the .NET MAUI App template.
    3. Select the project location, type the project name and press Enter.
    4. Then choose Create project

    Step 2: Install the Syncfusion® MAUI SignaturePad NuGet Package

    1. Press Ctrl + ` (backtick) to open the integrated terminal in Visual Studio Code.
    2. Ensure you’re in the project root directory where your .csproj file is located.
    3. Run the command dotnet add package Syncfusion.Maui.SignaturePad to install the Syncfusion® .NET MAUI SignaturePad package.
    4. To ensure all dependencies are installed, run dotnet restore.

    Step 3: Register the handler

    Syncfusion.Maui.Core nuget is a dependent package for all Syncfusion® controls of .NET MAUI. In the MauiProgram.cs file, register the handler for Syncfusion® core.

  • C#
  • using Syncfusion.Maui.Core.Hosting;
    
    namespace SignaturePadGettingStarted
    {
        public static class MauiProgram
        {
            public static MauiApp CreateMauiApp()
            {
                var builder = MauiApp.CreateBuilder();
                builder
                .UseMauiApp<App>()
                .ConfigureSyncfusionCore()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                });
    
                return builder.Build();
            }
        }
    }

    Step 4: Add a Basic SignaturePad

    Import the SfSignaturePad namespace and initialize the SignaturePad as shown below.

    <ContentPage
        . . .
        xmlns:signaturePad="clr-namespace:Syncfusion.Maui.SignaturePad;assembly=Syncfusion.Maui.SignaturePad">
        <Grid>
            <signaturePad:SfSignaturePad />
        </Grid>
    </ContentPage>
    using Syncfusion.Maui.SignaturePad;
    
    namespace SignaturePadGettingStarted
    {
        public partial class MainPage : ContentPage
        {
            public MainPage()
            {
                InitializeComponent();
                // Creating a SignaturePad control.
                SfSignaturePad signaturePad = new SfSignaturePad();
                this.content = signaturePad;
            }
        }
    }

    Prerequisites

    Before proceeding, ensure the following are set up:

    1. Ensure you have the latest version of JetBrains Rider.
    2. Install .NET 8 SDK or later is installed.
    3. Make sure the MAUI workloads are installed and configured as described here.

    Step 1: Create a new .NET MAUI Project

    1. Go to File > New Solution, Select .NET (C#) and choose the .NET MAUI App template.
    2. Enter the Project Name, Solution Name, and Location.
    3. Select the .NET framework version and click Create.

    Step 2: Install the Syncfusion® MAUI SignaturePad NuGet Package

    1. In Solution Explorer, right-click the project and choose Manage NuGet Packages.
    2. Search for Syncfusion.Maui.SignaturePad and install the latest version.
    3. Ensure the necessary dependencies are installed correctly, and the project is restored. If not, Open the Terminal in Rider and manually run: dotnet restore

    Step 3: Register the handler

    Syncfusion.Maui.Core nuget is a dependent package for all Syncfusion® controls of .NET MAUI. In the MauiProgram.cs file, register the handler for Syncfusion® core.

  • C#
  • using Syncfusion.Maui.Core.Hosting;
    
    namespace SignaturePadGettingStarted
    {
        public static class MauiProgram
        {
            public static MauiApp CreateMauiApp()
            {
                var builder = MauiApp.CreateBuilder();
                builder
                .UseMauiApp<App>()
                .ConfigureSyncfusionCore()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                });
    
                return builder.Build();
            }
        }
    }

    Step 4: Add a Basic SignaturePad

    Import the SfSignaturePad namespace and initialize the SignaturePad as shown below.

    <ContentPage
        . . .
        xmlns:signaturePad="clr-namespace:Syncfusion.Maui.SignaturePad;assembly=Syncfusion.Maui.SignaturePad">
        <Grid>
            <signaturePad:SfSignaturePad />
        </Grid>
    </ContentPage>
    using Syncfusion.Maui.SignaturePad;
    
    namespace SignaturePadGettingStarted
    {
        public partial class MainPage : ContentPage
        {
            public MainPage()
            {
                InitializeComponent();
                // Creating a SignaturePad control.
                SfSignaturePad signaturePad = new SfSignaturePad();
                this.content = signaturePad;
            }
        }
    }

    SignaturePad default

    Customize signature stroke color

    Customize the stroke color of the SignaturePad control by using the StrokeColor property. The default stroke color is Colors.Black.

    <signaturePad:SfSignaturePad StrokeColor="Red" />
    SfSignaturePad signaturePad = new SfSignaturePad()
    {
        StrokeColor = Colors.Red,
    };

    SignaturePad stroke color

    Customize signature stroke thickness

    The thickness of the stroke drawn can be customized by setting the MinimumStrokeThickness and MaximumStrokeThickness properties. The MinimumStrokeThickness defines the minimum thickness of the stroke and the MaximumStrokeThickness defines the maximum thickness of the stroke that can be drawn based on the speed and impression we provide through gesture within its minimum and maximum stroke thickness ranges. So that the signature will be more realistic.

    <signaturePad:SfSignaturePad MinimumStrokeThickness="1"
                                 MaximumStrokeThickness="6" />
    SfSignaturePad signaturePad = new SfSignaturePad()
    {
        MinimumStrokeThickness = 1,
        MaximumStrokeThickness = 6,
    };

    SignaturePad stroke thickness

    Saving the signature as an image

    Save the signature drawn in the SignaturePad as an ImageSource using the ToImageSource() method which can further be synchronized with your devices and documents that need your signature.

    <signaturePad:SfSignaturePad x:Name="signaturePad" />
    <Button Text="Save"
            Clicked="OnSaveButtonClicked" />
    SfSignaturePad signaturePad = new SfSignaturePad();
    Button saveButton = new Button();
    saveButton.Clicked += OnSaveButtonClicked;
    
    private void OnSaveButtonClicked(object? sender, EventArgs e)
    {
        ImageSource? source = signaturePad.ToImageSource();
    }

    Clear the existing signature in SignaturePad

    Clear the signature drawn in the SignaturePad using the Clear() method as shown in the code snippet below:

    <signaturePad:SfSignaturePad x:Name="signaturePad" />
    <Button Text="Clear"
            Clicked="OnClearButtonClicked" />
    SfSignaturePad signaturePad = new SfSignaturePad();
    Button clearButton = new Button();
    clearButton.Clicked += OnClearButtonClicked;
    
    private void OnClearButtonClicked(object? sender, EventArgs e)
    {
        ImageSource? source = signaturePad.Clear();
    }

    Events

    DrawStarted

    This event will be triggered when we start drawing in the SignaturePad. With this, CancelEventArgs will be passed. Also, restrict the draw start action by setting e.cancel as true.

    <signaturePad:SfSignaturePad DrawStarted="OnDrawStarted" />
    SfSignaturePad signaturePad = new SfSignaturePad()
    { 
        DrawStarted += OnDrawStarted
    };
    private void OnDrawStarted(object? sender, CancelEventArgs e)
    {
        e.Cancel = false;
    }

    DrawCompleted

    This event will be triggered when we complete the drawing in the SignaturePad.

    <signaturePad:SfSignaturePad DrawCompleted="OnDrawCompleted" />
    SfSignaturePad signaturePad = new SfSignaturePad()
    {
        DrawCompleted += OnDrawCompleted
    };
    private void OnDrawCompleted(object? sender, EventArgs e)
    {
    }

    Method

    Get Signature Points

    Users can use the GetSignaturePoints method to retrieve the drawn signature points from the SfSignaturePad.

    <signaturePad:SfSignaturePad x:Name="signaturePad"
                                 StrokeColor="Red"
                                 MinimumStrokeThickness="1"
                                 MaximumStrokeThickness="6" 
                                 DrawCompleted="OnDrawCompleted"/>
    SfSignaturePad signaturePad = new SfSignaturePad()
    {
        StrokeColor = Colors.Red,
        MinimumStrokeThickness = 1,
        MaximumStrokeThickness = 6, 
        DrawCompleted += OnDrawCompleted
    };
    
    private void OnDrawCompleted(object? sender, EventArgs e)
    {
        List<List<float>> pointsCollection = new List<List<float>>();
        pointsCollection = signaturePad.GetSignaturePoints();
    }

    NOTE

    You can refer to our .NET MAUI SignaturePad feature tour page for its groundbreaking feature representations. You can also explore our .NET MAUI SignaturePad Example that shows you how to render the SignaturePad in .NET MAUI.