Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 24250 [details]
Good day Xamarin support team.
We are trying to implement a native view in Android but linking with a ViewModel in a PCL using Xamarin Forms binding.
Although using SetBinding from NativeBindingExtensions seems straightforward, when I bind to an EditText, the viewmodel get notified of property updates but the caret is moved always to the start, such is a wrong behaviour.
The attached project shows how while I am tapping the softkeyboard in an EditText the caret is always at start.
The login form of the project is just an example. We are trying to achieve this because of PM requirements to an existing Xamarin Forms project, so if there is a better way to get native UI using Xamarin Forms binding, without using other MVVM framework, with native Android widgets and existing viewmodels, we are open to options.
When you set the bindings on the native EditText controls, do not pass in an updateSourceEventName parameter, e.g:
> editTextPhoneNumber.SetBinding(nameof(EditText.Text), new Binding(nameof(LoginPageViewModel.PhoneNumber), BindingMode.TwoWay));
By doing not doing this, the carat remains at the end of the text as expected. Since you are already subscribed to the control's TextChanged event, the handler is running twice and that might be causing the carat to be "reset" in this case.
Hope this helps!