我在radio buttons
内显示listview
并绑定了onClick
,但我收到了绑定失败错误。
下面是我的ListView:
<Mvx.MvxListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/listview"
local:MvxBind="ItemsSource QuestionList; ItemClick ChoiceCheckedClick"
local:MvxItemTemplate="@layout/item_questions"
android:clickable="true"
android:layout_margin="10dp"
android:layout_marginBottom="20dp" />
项目模板:
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton1"
android:textColor="#000000"
android:clickable="true"
local:MvxBind="Text OptionA; onClick choiceClicked" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
local:MvxBind="Text OptionB"
android:id="@+id/radioButton2" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
local:MvxBind="Text OptionC"
android:id="@+id/radioButton3" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
local:MvxBind="Text OptionD"
android:id="@+id/radioButton4" />
</RadioGroup>
我的视图模型:
private IMvxCommand _choiceCheckedClick;
public IMvxCommand ChoiceCheckedClick
{
get
{
_choiceCheckedClick = _choiceCheckedClick ?? new MvxCommand<Question>(btnClick);
return _choiceCheckedClick;
}
}
public void btnClick(Question item)
{
//Do something
}
My Wrapper课程:
namespace EducationAppPCL.Utility
{
public class QuestionWrapper
{
Question _questionItem;
QuestionsViewModel _questionViewModel;
public QuestionWrapper(Question questionItem, QuestionsViewModel questionViewModel)
{
_questionItem = questionItem;
_questionViewModel = questionViewModel;
}
public IMvxCommand choiceClicked
{
get
{
return new MvxCommand(() => _questionViewModel.btnClick(_questionItem));
}
}
public Question QuestionItem
{
get
{
return _questionItem;
}
}
}
以下是我的模特:
public class Question
{
// [AutoIncrement,PrimaryKey]
[PrimaryKey]
public int Id { get; set; }
public Nullable<int> AssignmentId { get; set; }
public string QuestionText { get; set; }
public string Description { get; set; }
public string Options { get; set; }
public Nullable<int> Score { get; set; }
public string Type { get; set; }
public string OptionA { get; set; }
public string OptionB { get; set; }
public string OptionC { get; set; }
public string OptionD { get; set; }
public bool RadioVisible { get; set; }
public bool TexboxVisible { get; set; }
public bool SubmitVisible { get; set; }
public bool NextVisible { get; set; }
public bool OptionASelected { get; set; }
public bool OptionBSelected { get; set; }
public bool OptionCSelected { get; set; }
public bool OptionDSelected { get; set; }
public string AnswerGiven { get; set; }
public bool choiceClicked { get; set; }
public string CreatedDate { get; set; }
public string ModifiedDate { get; set; }
我收到了以下错误:
[0:]
MvxBind:Warning: 15.50 Failed to create target binding for binding onClick for choiceClicked
[0:] MvxBind:Warning: 15.50 Failed to create target binding for binding onClick for choiceClicked
09-11 10:51:07.880 I/mono-stdout( 1929): MvxBind:Warning: 15.50 Failed to create target binding for binding onClick for choiceClicked
[0:]
09-11 10:51:07.900 W/EGL_genymotion( 1929): eglSurfaceAttrib not implemented
MvxBind:Warning: 15.53 Failed to create target binding for binding onClick for choiceClicked
[0:] MvxBind:Warning: 15.53 Failed to create target binding for binding onClick for choiceClicked
09-11 10:51:07.908 I/mono-stdout( 1929): MvxBind:Warning: 15.53 Failed to create target binding for binding onClick for choiceClicked
[0:]
MvxBind:Warning: 15.54 Failed to create target binding for binding onClick for choiceClicked
[0:] MvxBind:Warning: 15.54 Failed to create target binding for binding onClick for choiceClicked
09-11 10:51:07.920 I/mono-stdout( 1929): MvxBind:Warning: 15.54 Failed to create target binding for binding onClick for choiceClicked