I'm trying using fire MvxCommand with CommandParameter, but faced with 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 param variable is null.
What I'm doing wrong?