C# 4.0 MvxBind:无法为绑定创建目标绑定?
我正在C# 4.0 MvxBind:无法为绑定创建目标绑定?,c#-4.0,xamarin,xamarin.android,mvvmcross,C# 4.0,Xamarin,Xamarin.android,Mvvmcross,我正在列表视图中显示单选按钮,并在单击时绑定了单选按钮,但我发现绑定失败错误。 下面是我的列表视图: <Mvx.MvxListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/listview" local:MvxBind="I
列表视图中显示单选按钮
,并在单击时绑定了单选按钮
,但我发现绑定失败错误。
下面是我的列表视图:
<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" />
以下是我的模型:
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; }
尝试使用Click
而不是onClick
当我使用Click event时,它会禁用单选按钮,是的,它也会显示绑定失败。有什么想法吗??
private IMvxCommand _choiceCheckedClick;
public IMvxCommand ChoiceCheckedClick
{
get
{
_choiceCheckedClick = _choiceCheckedClick ?? new MvxCommand<Question>(btnClick);
return _choiceCheckedClick;
}
}
public void btnClick(Question item)
{
//Do something
}
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