【发布时间】:2015-09-10 14:25:06
【问题描述】:
我正在尝试使用火 MvxCommand 和 CommandParameter:
<Mvx.MvxListView
style="@style/MyList"
local:MvxBind="ItemsSource Items;"
local:MvxItemTemplate="@layout/itemfavorite" />
这是我在ViemModel的财产:
public List<Data> Items
{
get { return _items; }
set
{
_items = value;
RaisePropertyChanged(() => Items);
}
}
这是我的model:
public class Data
{
public int Id{get;set;}
public string Name {get;set;}
public ICommand Action {get;set;}
}
这是我的command(在数据中使用):
public ICommand MyCommand
{
get
{
return new MvxCommand<int>(async (id) =>
{
.....
}
}
这是我的MvxItemTemplate:
……
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start"
android:layout_margin="10dp"
local:MvxBind="Click Action,CommandParameter=Id"/>
如果我使用“CommandParameter=Id” - 我会得到 unhandle 异常。 “CommandParameter=1” - 这是工作。但我需要传递一个 CommandParameter 值字段 ID。有可能吗?
【问题讨论】:
标签: android exception binding xamarin mvvmcross