We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to restrict the values of SfNumericUpDown within certain range.

Platform: Xamarin.Forms |
Control: SfNumericUpDown |
Published Date: April 27, 2017 |
Last Revised Date: July 4, 2019

Syncfusion SfNumericUpDown provides Minimum and Maximum property support to restrict values to certain range.

 

To set Minimum and Maximum property:

 

Step 1: Set Value for the Minimum and Maximum property

 

Step 2: The values in SfNumericUpDown will be within the range based on the value given for Minimum and Maximum property.

 

The below code illustrates the way to achieve this.

Code Snippet

 

XAML Code:

 

<?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:NumericUpDown"
xmlns:numeric="clr-namespace:Syncfusion.SfNumericUpDown.XForms;assembly=Syncfusion.SfNumericUpDown.XForms"
x:Class="NumericUpDown.MainPage">
<ContentPage.Content>
<StackLayout HeightRequest="150" >
<numeric:SfNumericUpDown x:Name="sfNumericUpDown" Minimum="10" Maximum="60" HeightRequest="100"  Value="20" AllowNull="false" TextAlignment="Center" SpinButtonAlignment="Both" FormatString="n"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
 

 

C# Code:

 

namespace NumericUpDown
{
 
public partial class MainPage : ContentPage
{
 
    SfNumericUpDown numeric;
    public MainPage()
    {
        InitializeComponent();
        numeric = new SfNumericUpDown();
        numeric.Minimum = 10;
        numeric.Maximum = 60;
        numeric.Value = 20;
        numeric.TextAlignment = TextAlignment.Center;
        numeric.SpinButtonAlignment = SpinButtonAlignment.Both;
        numeric.HeightRequest = 100;
        numeric.AllowNull = false;
        StackLayout stack = new StackLayout();
        stack.Children.Add(numeric);
        this.Content = stack;
    }
}
}
 

 

 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon