我已将视图布局定义如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Mvx.MvxListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxBind="ItemClick PopulateMetricsCat2Command ; ItemsSource RatingList"
local:MvxItemTemplate="@layout/item_met2" />
</LinearLayout>
和List ItemTemplate如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
local:MvxBind="Text MetricName" />
<RatingBar
android:id="@+id/ratingbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="1"
local:MvxBind="Rating ResponseValue" />
</LinearLayout>
我已经在My MvxListView中对 ItemClick 事件绑定了一个命令,但每当我从List中选择一个项目时,指定的命令就不会被执行 .Control是nat get转移到命令。
该命令如下
private void DoGoPopulateMetrics(UserRating r)
{
ShowViewModel<PopulateMetricsByCat2ViewModel>(r);
}
为什么不调用此命令?
private Cirrious.MvvmCross.ViewModels.MvxCommand<StarRating>
_ratingSelectedCommand;
public System.Windows.Input.ICommand ItemSelectedCommand
{
get{
_ratingSelectedCommand = _ratingSelectedCommand ?? new
Cirrious.MvvmCross.ViewModels.MvxCommand<StarRating>(DoSelectItem);
return _ratingSelectedCommand;
}
}
private void DoSelectItem(StarRating r)
{
ShowViewModel<PopulateMetricsByCat2ViewModel>(r);
}
答案 0 :(得分:1)
您缺少PopulateMetricsCat2Command
public ICommand PopulateMetricsCat2Command
{
get { return new MvxCommand(DoGoPopulateMetrics); }
}