Articles in this section
Category / Section

How to create a NumericTextBox control sample using Xaml

1 min read

NumericTextBox is an advanced version of the Entry control that restricts input to numeric values. We can create this control either using C# level code or in Xaml level code. Here we are going to write NumericTextBox control creation with Xaml level code.

 

Creation of NumericTextBox control:

Step 1: Import the NumericTextBox namespace

xmlns:Synfusion="clr-namespace:Syncfusion.SfNumericTextBox.XForms;assembly=Syncfusion.SfNumericTextBox.XForms" 

 

Step 2: Initialize the NumericTextBox control as the content of content page

 

 <Synfusion:SfNumericTextBox  x:Name="sfNumericTextBox" />

 

Step 3: Add the necessary properties on it.

 

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:KBSolution"
    xmlns:Synfusion="clr-namespace:Syncfusion.SfNumericTextBox.XForms;assembly=Syncfusion.SfNumericTextBox.XForms"
    x:Class="KBSolution.KBSolutionPage">
<ContentPage.Content>
    <Grid  BackgroundColor="#E4EAF0">
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
          <Label x:Name="firstNumeric" Text="NumericTextBox" FontSize="20" HorizontalOptions="Center"  FontAttributes="Bold" HorizontalTextAlignment="Start" VerticalTextAlignment="Start"/>
          <Synfusion:SfNumericTextBox 
            Grid.Row="1"
            WidthRequest="180" 
            ParserMode="Decimal" 
            HorizontalOptions="Center"  
            HeightRequest="40" 
            MaximumNumberDecimalDigits="3" 
            AllowNull="true" 
            BorderColor="Blue" 
            TextColor="Maroon" 
            x:Name="sfNumericTextBox"
            Value="1000" 
            FormatString="p" 
            ValueChangeMode="OnKeyFocus" 
            PercentDisplayMode="Value"
            FontSize="20" />
        </Grid >
</ContentPage.Content>
</ContentPage>

 

SfNumericTextBox using XAML

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied