使用MvxCommand随着CommandParameter结合 [英] Using MvxCommand With CommandParameter binding

查看:180
本文介绍了使用MvxCommand随着CommandParameter结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用火 MvxCommand与CommandParameter ,但面对有以下的问题:
MyView.axml包括:

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:

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
          }
      });
    }
}

但是,当我检查参数变量的无效

我在做什么错了?

推荐答案

您code为我工作的头我的源代码树。

Your code is working for me on the Head of my source tree.

但此功能只有两周。

我的猜测是,这个功能既没有使它成为你正在使用或有与它的错误释放。

My guess is that this feature either didn't make it into the release that you are working with or there was a bug with it.

您可以检查您的调试跟踪此绑定?有没有什么信息?

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


  • 如果跟踪表明, CommandParameter 然后一个未知的符号我的猜测是,你要么需要自己构建最新的源 - 或者等待新版本。

  • 如果跟踪建议别的东西,那么你也许可以在安装过程中修补这个问题。

  • If the trace suggests that CommandParameter is an unknown symbol then my guess is that you will need to either build the latest source yourself - or to wait for a new release.
  • If the trace suggests something else then you may be able to patch the problem during setup.

有一件事我知道我们所做的修复是一个价值转换问题,即 Cirrious.MvvmCross.Binding.dll 根据 ValueConverter 的不只是被覆盖 Setup.ValueConverterAssemblies 注册 ValueConverter 需要这种 CommandParameter

One thing I know we did fix was a value converter issue where the Cirrious.MvvmCross.Binding.dll based ValueConverter's weren't being just by overriding Setup.ValueConverterAssemblies to register the ValueConverter required for this CommandParameter

这篇关于使用MvxCommand随着CommandParameter结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆