Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

iOS Numeric Keyboard removes Comma

$
0
0

I have created a NumericEntry with a Numeric Keyboard. The Keyboard correctly shows a Comma in the Seperator box according to my Phones Region setting.

Unfortunately for some reason, the Comma is always automatically removed.
Example - I try to enter 1,8, but when running in iOS, the App just removes the comma and makes it 18.


I have some Custom code to add the Done button, to allow user to remove keyboard, but other than that, im running entirely standard setup.
How can i change the code, to allow users to enter Comma's?

XAML:

<local:NumericEntry Text="{Binding Antal, Mode=TwoWay}"
                       Style="{StaticResource AntalEntry}"
                       Grid.Column="1"
                       HorizontalOptions="FillAndExpand"
                       HorizontalTextAlignment="End">
</local:NumericEntry>

iOS Custom Renderer

    public class NumericEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Entry> e)
        {
            base.OnElementChanged(e);
            if (Control != null)
            {
                Control.KeyboardType = UIKit.UIKeyboardType.DecimalPad;
                AddDoneButton(Control);
            }
        }



        /// <summary>
        /// Add toolbar with Done button
        /// </summary>
        protected void AddDoneButton(UITextField uiTextField)
        {
            UIToolbar toolbar = new UIToolbar(new RectangleF(0.0f, 0.0f, 50.0f, 44.0f));

            var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate
            {
                uiTextField.ResignFirstResponder();
            });

            toolbar.Items = new UIBarButtonItem[] {
                new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace),
                doneButton
            };

            uiTextField.InputAccessoryView = toolbar;
        }
    }

Viewing all articles
Browse latest Browse all 204402

Trending Articles