AXML:
<Button
android:id="@+id/greenButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Green"
local:MvxBind="Click ShowColorCommand, CommandParameter='Green'"/>
和ViewModel:
public class MainViewModel
: MvxViewModel
{
public ICommand ShowColorCommand
{
get
{
return new MvxCommand(() => ShowViewModel<ColorViewModel>(new { color = ??? } ));
}
}
}
如何从命令中的.axml('Green')中读取/使用CommandParameter?我需要在“???”
中加入什么任何帮助表示赞赏
答案 0 :(得分:2)
使用通用MvxCommand<T>
表单 - Using MvxCommand With CommandParameter binding
new MvxCommand<string>(param =>
{
if (param == "foo")
{
// do something
}
else if (param == "bar")
{
// do something else
}
});