问题
I am trying to add an event that's triggered by the TextFieldShouldReturn inside a Monotouch.Dialog entry element. I am currently trying to attach an event like so:
//create the entry element
EntryElement newEntry = new EntryElement(thisQuestion.Text, "tap to type", null);
//add should return
newEntry.ShouldReturn(addAnswerToSurvey(newEntry.Value, thisQuestion.Index));
//add the entry to the section
aSection.Add(newEntry);
I get an error back on build: 'MonoTouch.Dialog.EntryElement.ShouldReturn' can only appear on the left hand side of += or -= when used outside of the type 'MonoTouch.Dialog.EntryElement' (CS0070)
I have heard of people not being able to get data out of Monotouch.Dialog statements, and that's seems to be what this error might suggest. So... Is is possible to implement the text field should return delegate on an entry element, if so, how? If not, is it just there because the entry element contains a text field?
回答1:
Eric, you need to use:
newEntry.ShouldReturn += () => { ... }
来源:https://stackoverflow.com/questions/11634752/trying-to-add-event-to-shouldreturn-on-an-entry-element