Notice: After Volume 1 2025 (Mid of March 2025), updates, bug fixes, and feature enhancements for this control will no longer be available in the Syncfusion® package. Please switch to the Syncfusion® Toolkit for .NET MAUI for continued support. For a smooth transition refer this migration document.

Getting Started with .NET MAUI Numeric Entry

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

To quickly get started with the .NET MAUI Numeric Entry, 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 Inputs NuGet Package

  1. In Solution Explorer, right-click the project and choose Manage NuGet Packages.
  2. Search for Syncfusion.Maui.Inputs 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 Microsoft.Maui;
    using Microsoft.Maui.Hosting;
    using Microsoft.Maui.Controls.Compatibility;
    using Microsoft.Maui.Controls.Hosting;
    using Microsoft.Maui.Controls.Xaml;
    using Syncfusion.Maui.Core.Hosting;
    
    namespace MaskedEntrySample
    {
        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 Numeric Entry

    Step 1: Add the namespace as shown in the following code sample.

    <xmlns:editors="clr-namespace:Syncfusion.Maui.Inputs;assembly=Syncfusion.Maui.Inputs"/>
    using Syncfusion.Maui.Inputs;

    Step 2: Add the SfNumericEntry control with a required optimal name using the included namespace.

    <editors:SfNumericEntry x:Name="numericEntry" />
    SfNumericEntry sfNumericEntry = new SfNumericEntry();

    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 Inputs 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.Inputs to install the Syncfusion® .NET MAUI Inputs 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 Microsoft.Maui;
    using Microsoft.Maui.Hosting;
    using Microsoft.Maui.Controls.Compatibility;
    using Microsoft.Maui.Controls.Hosting;
    using Microsoft.Maui.Controls.Xaml;
    using Syncfusion.Maui.Core.Hosting;
    
    namespace MaskedEntrySample
    {
        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 Numeric Entry

    Step 1: Add the NuGet to the project as discussed in the above reference section.

    Step 2: Add the namespace as shown in the following code sample.

    <xmlns:editors="clr-namespace:Syncfusion.Maui.Inputs;assembly=Syncfusion.Maui.Inputs"/>
    using Syncfusion.Maui.Inputs;

    Step 3: Add the SfNumericEntry control with a required optimal name using the included namespace.

    <editors:SfNumericEntry x:Name="numericEntry" />
    SfNumericEntry sfNumericEntry = new SfNumericEntry();

    .NET MAUI NumericEntry Application

    Editing the value

    By default, the NumericEntry control allows you to enter numeric input and restricts the alphabetic input. Once the Enter key is pressed or control focus is lost, the value of the NumericEntry control is validated and updated based on the format applied.

    <editors:SfNumericEntry WidthRequest="200"
                            HorizontalOptions="Center" 
                            VerticalOptions="Center" 
                            CustomFormat="0.000" />
    SfNumericEntry numericEntry = new SfNumericEntry();
    numericEntry.WidthRequest=200;
    numericEntry.HorizontalOptions = LayoutOptions.Center;
    numericEntry.VerticalOptions = LayoutOptions.Center;
    numericEntry.CustomFormat = "0.000";

    .NET MAUI NumericEntry value editing

    Change number format

    You can change the format in which the value should be displayed using the CustomFormat property. By default, the value of the CustomFormat property is null.

    <editors:SfNumericEntry WidthRequest="200"
                            HorizontalOptions="Center"
                            VerticalOptions="Center"
                            Value="12.5" 
                            CustomFormat="C2" />
    SfNumericEntry numericEntry = new SfNumericEntry();
    numericEntry.WidthRequest=200;
    numericEntry.HorizontalOptions = LayoutOptions.Center;
    numericEntry.VerticalOptions = LayoutOptions.Center;
    numericEntry.Value = 12.5;
    numericEntry.CustomFormat = "C2";

    .NET MAUI NumericEntry value editing

    Accept null value

    By default, the NumericEntry control allows a null value. A null value is assigned when the user clicks the clear button or clears the input. You can disable this by setting the value of the AllowNull property as false. When the value of the AllowNull property is set to false, and the input is cleared, the NumericEntry control returns it to 0.

    <editors:SfNumericEntry WidthRequest="200"
                            HorizontalOptions="Center"
                            VerticalOptions="Center"
                            Value="12315"
                            AllowNull="False" />
    SfNumericEntry sfNumericEntry = new SfNumericEntry();
    sfNumericEntry.WidthRequest=200;
    sfNumericEntry.Value=12315;
    sfNumericEntry.HorizontalOptions = LayoutOptions.Center;
    sfNumericEntry.VerticalOptions = LayoutOptions.Center;
    sfNumericEntry.AllowNull = false;

    .NET MAUI NumericEntry prevent empty textbox