Articles in this section
Category / Section

How to remove a thousand separators in the numeric text field in Xamarin.Forms DataForm (SfDataForm)

2 mins read

You can disabled the thousand seperators for numeric Editor in Xamarin.Forms SfDataForm by using EnableGroupSeparator property.

 

Refer to the online user guide documentation for customize the editor in DataForm using  AutoGeneratingDataFormItem event. 

 

C#

Set the EnableGroupSeparator property into false inside the AutoGeneratingDataFormItem event.

public class DataFormBehavior : Behavior<ContentPage>
    {
        SfDataForm dataForm;
        protected override void OnAttachedTo(ContentPage bindable)
        {
            base.OnAttachedTo(bindable);
            dataForm = bindable.FindByName<SfDataForm>("dataForm");
            dataForm.AutoGeneratingDataFormItem += DataForm_AutoGeneratingDataFormItem;
        }
        private void DataForm_AutoGeneratingDataFormItem(object sender, AutoGeneratingDataFormItemEventArgs e)
        {
            if (e.DataFormItem != null)
            {
                if (e.DataFormItem.Name == "BirthYear")
                {
                    (e.DataFormItem as DataFormNumericItem).EnableGroupSeparator = false;
                }
            }
        }
        protected override void OnDetachingFrom(ContentPage bindable)
        {
            base.OnDetachingFrom(bindable);
            dataForm.AutoGeneratingDataFormItem -= DataForm_AutoGeneratingDataFormItem;
        }
    }

 

View Sample in GitHub

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