c# - How to pass argument to Event Handler in Xamarin IOS -
how pass string argument eventhandler?
viewcontroller(a) written event handler
public event eventhandler valuechanged; void responsecompleted(object sender, commoncode.responseeventargs e){ this.invokeonmainthread (delegate { if (valuechanged != null) { valuechanged (this, new eventargs (e.responsedata)); // e.responsedata string datatype. } }); }
viewcontroller(b)
relateddatasource.valuechanged += delegate { response data viewcontrollera }
you can use generic eventhandler. example:
public event eventhandler<string> valuechanged; void responsecompleted(object sender, commoncode.responseeventargs e){ this.invokeonmainthread (delegate { var handler = valuechanged; if (handler != null) handler(this, e.responsedata); }); } relateddatasource.valuechanged += (s, responsedata) => { //your data in responsedata variable }
Comments
Post a Comment