I have an Entry and an Editor. Their Text property is binded to my ViewModel. I would like to raise the binding when the user finishes/completes its input. By default, if a user types "blabla", the binding is raised for each character (6 times). I want to raise the binding when the control gets "Unfocused" or "Completed" (2 events available on those controls). Thus, the binding will only be raised when the typing is finished.
For this purpose, I have tried to use either
Text="{Binding MyText, UpdateSourceEventName=Completed}"
or
Text="{Binding Text, UpdateSourceEventName=Unfocused}"
But they both don't work.
Steps to Reproduce
Add an Entry or an Editor control
Create a string property with INPC in the ViewModel
Bind the Text property of the Entry/Editor
Add UpdateSourceEventName=Unfocused (or Completed) in the binding.
You must have something similar to Text="{Binding TheStringProperty, UpdateSourceEventName=Unfocused}" (or Completed)
Expected Behavior
The binding is raised only once : when either the control is unfocused or the inputs is validated/completed.
Actual Behavior
The binding is raised on each key touched instead of when the input is complete.
Version with issue: Xamarin Forms 4.4.0.991265
Last known good version: ?
IDE: Visual Studio 2019
Platform Target Frameworks:
iOS: 13.10.0.17 (5f802ef)
Android: 10.1.4.0 (d16-4/e44d1ae)
Workaround
Instead of using a binding to the string property, use a CommandBehavior and bind to the Unfocused event to the Command.
In the command, you set the string property with the text provided thanks to a binding : Parameter to the Text property of the control (with x:Reference)
Description
I have an Entry and an Editor. Their Text property is binded to my ViewModel. I would like to raise the binding when the user finishes/completes its input. By default, if a user types "blabla", the binding is raised for each character (6 times). I want to raise the binding when the control gets "Unfocused" or "Completed" (2 events available on those controls). Thus, the binding will only be raised when the typing is finished.
For this purpose, I have tried to use either Text="{Binding MyText, UpdateSourceEventName=Completed}" or Text="{Binding Text, UpdateSourceEventName=Unfocused}"
But they both don't work.
Steps to Reproduce
Expected Behavior
The binding is raised only once : when either the control is unfocused or the inputs is validated/completed.
Actual Behavior
The binding is raised on each key touched instead of when the input is complete.
Workaround
Instead of using a binding to the string property, use a CommandBehavior and bind to the Unfocused event to the Command. In the command, you set the string property with the text provided thanks to a binding : Parameter to the Text property of the control (with x:Reference)
Exemple given :