mvvmlight icon indicating copy to clipboard operation
mvvmlight copied to clipboard

[Android] Command binding throws System.InvalidCastException

Open Opachl opened this issue 6 years ago • 2 comments

Platform: Android Version: GalaSoft.MvvmLight.Platform, Version=5.4.1.0

Pseudo-Code for Bug Description

Query = root.FindViewById<SearchView>(Resource.Id.search); Query.SetCommand<QueryTextSubmitEventArgs>("QueryTextSubmit", ViewModel.TestCMD);

This throws always System.InvalidCastException: Specified cast is not valid.

I also tried other overloads and combinations result is Always the same

Opachl avatar Jun 28 '18 13:06 Opachl

Hi, I can confirm above issue. I face the same problem when i'm trying to set command on EditText's event.

id = FindViewById<EditText>(Resource.Id.edit_id); id.SetCommand("FocusChange", Vm.IdCommand);

Temporary workaround is:

id.FocusChange += (a, b) => { if (Vm.IdCommand.CanExecute(b)) Vm.IdCommand.Execute(b); };

MichalPetryk avatar Jul 13 '18 08:07 MichalPetryk

isn't this exact situation described in the documentation here?: http://www.mvvmlight.net/doc/xam1.cshtml

MichaelShapiro avatar Mar 27 '19 18:03 MichaelShapiro