2012-07-24 45 views
0

我想添加一个由TextFieldShouldReturn在Monotouch.Dialog条目元素内触发的事件。目前我正在试图附加一个事件,像这样:尝试将事件添加到.Should返回入口元素

//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); 

我得到一个错误重新编译:“MonoTouch.Dialog.EntryElement.ShouldReturn”只能出现在的+ =或左边 - =当在“MonoTouch.Dialog.EntryElement”类型外部使用(CS0070)

我听说有人无法从Monotouch.Dialog语句中获取数据,而这似乎是此错误可能表明的原因。所以... 是可以实现的文本字段应该返回一个入口元素的委托,如果是这样,如何?如果没有,那是因为entry元素包含一个文本字段吗?

+0

thisQuestion和的.text和的.index是在我的代码自定义字符串... – 2012-07-24 15:58:25

回答

1

埃里克,你需要使用:

newEntry.ShouldReturn + =()=> {...}

+0

谢谢米格尔!这很好。 – 2012-07-27 20:31:21