Using MvxCommand with CommandParameter Binding

I am trying to use fire MvxCommand with CommandParameter , but encountered the following problem: MyView.axml contains:

<LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" local:MvxBind="Click MyCommand, CommandParameter=foo" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button2" local:MvxBind="Click MyCommand, CommandParameter=bar" /> </LinearLayout> 

MyViewModel.cs:

 public class MyViewModel : MvxViewModel { public ICommand MyCommand { get; private set; } public MyViewModel() { // param is null MyCommand = new MvxCommand<string>(param => { if (param == "foo") { // do something } else if (param == "bar") { // do something else } }); } } 

But when I check the param null variable.

What am I doing wrong?

+6
source share
1 answer

Your code works for me in the chapter of my source tree.

But this functionality is only two weeks old.

I assume that this function either did not make it to the release you are working with, or there was an error with it.

Can you check your debug trace for this binding? Is there any information there?

  • If the trace assumes that the CommandParameter is an unknown character, then I assume that you need to either build the most recent source yourself, or wait for the new version.
  • If the trace offers something else, then you can fix the problem during installation.

One thing I know we fixed is a value converter problem where Cirrious.MvvmCross.Binding.dll based on ValueConverter not just an override of Setup.ValueConverterAssemblies to register the ValueConverter needed for this CommandParameter

+8
source

Source: https://habr.com/ru/post/947833/


All Articles