Trying to add event to .ShouldReturn on an Entry Element

99封情书 提交于 2020-01-06 08:21:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!