2

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'"/>

和视图模型:

public class MainViewModel
    : MvxViewModel
{
    public ICommand ShowColorCommand
    {
        get
        {
            return new MvxCommand(() => ShowViewModel<ColorViewModel>(new { color = ??? } ));
        }
    }
}

如何在我的命令中读取/使用来自 .axml('Green')的 CommandParameter?我需要在“???”里面放什么?

任何帮助表示赞赏

4

1 回答 1

2

使用通用MvxCommand<T>形式 - Using MvxCommand With CommandParameter binding中有一个字符串示例

new MvxCommand<string>(param =>
  {
      if (param == "foo")               
      {
        // do something
      }
      else if (param == "bar")
      {
        // do something else
      }
  });
于 2013-10-17T10:09:25.553 回答