0

I have some problem with Xamarin forms on Completed event which has been triggered when the control have focus (Entry)

Below is the View :

  <Entry
                x:Name="EntryOrderNumber"
                Placeholder="MFGO Number"
                Text="{Binding TextOrderEntry}" />

  <Entry
                x:Name="EntryMachineNumber"
                Placeholder="Machine Number"
                Text="{Binding TextMachineEntry}" />

And this is where I control the even which is placed at view.cs

public ProductionOrderPage()
        {
            InitializeComponent();
            BindingContext = App.Locator.ProductionOrderPageVM;
            EntryOrderNumber.Completed += EntryOrderNumber_Completed;
            EntryMachineNumber.Completed += EntryMachineNumber_Completed;
            EntryTotalPosition.Completed += EntryTotalPosition_Completed;


        }

        private void EntryMachineNumber_Completed(object sender, EventArgs e)
        {
            EntryMachineNumber.Unfocus();         
            EntryTotalPosition.Focus();
        }

        private void EntryOrderNumber_Completed(object sender, EventArgs e)
        {
            EntryOrderNumber.Unfocus();            
            EntryMachineNumber.Focus();
        }

My problem is : While the Entry (Text field) has focused , the Completed event has been triggered which resulting in the focus will go to another field continuously as per set in the Completed event.

  • the apps being debugged and deployed onto emulator

  • using MVVMlight

Thanks a lot

jgoldberger - MSFT
  • 5,978
  • 2
  • 20
  • 44
anevil
  • 837
  • 3
  • 11
  • 24
  • I can not reproduce this with a pure Xamarin.Form bindings , i.e. not using MVVMLight. In my test Completed event is only fired when user presses return. I wonder if somehow MVVMLight is inserting a return character when setting the binding, thus causing the Completed event to fire? – jgoldberger - MSFT Dec 30 '16 at 01:29
  • when I do some other details test, looks like the Return key is actually executed twice. – anevil Dec 30 '16 at 03:56

1 Answers1

0

using soft keyboard instead of hardware keyboard solve this problems. Weird.

Enabling soft keyboard : Visual Studio Android Emulator Display Keyboard

Community
  • 1
  • 1
anevil
  • 837
  • 3
  • 11
  • 24