2013-06-21 46 views
6

我用火MvxCommand with CommandParameter努力,但面臨着以下問題: MyView.axml包含:使用MvxCommand隨着CommandParameter結合

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

但是當我檢查param variable is null

我在做什麼錯了?

回答

8

您的代碼在我的源代碼樹的頭部上工作。

但是這個功能只有兩個星期的時間。

我的猜測是,這個功能要麼沒有進入你正在使用的版本,要麼是它有一個錯誤。

你可以檢查你的調試跟蹤這個綁定?那裏有任何信息嗎?

  • 如果跟蹤表明CommandParameter是一個未知的符號,那麼我的猜測是您將需要自己構建最新源代碼或等待新版本。
  • 如果跟蹤顯示其他內容,則可以在安裝過程中修補問題。

有一件事我知道我們並修復了其中Cirrious.MvvmCross.Binding.dll基於ValueConverter的沒有被覆蓋Setup.ValueConverterAssemblies註冊這個CommandParameter

+0

你說的沒錯,司徒所需的ValueConverter僅僅是一個值轉換器問題! 登錄者觀看需要: ** MvxBind:警告:132,54找不到命名轉換CommandParameter I/MvxBind(18314):132,53找不到命名轉換CommandParameter I /單標準輸出(18314):MvxBind :警告:132,53找不到命名的轉換器CommandParameter ** 何時可以預期最近的版本? –

+0

@Stuart我正在嘗試相同的'本地:MvxBind =「點擊OnRemoveClick,CommandParameter =。」'我得到相同的。「。同時執行commmand。有什麼想法嗎? – RIYAZ

+0

對不起 - 聽起來你沒有像這個2013年的問題一樣獲得「相同」。可能是最好在一個新問題中完全解釋你的問題? – Stuart