Given the following code, how can I pass data from "First Name", "Last Name", etc. into my method BookASession.SendMessage();
?
RootElement CreateBookASessionRoot()
{
return new RootElement("Book a Session") {
new Section() {
new EntryElement("First Name", "First Name", ""),
new EntryElement("Last Name", "Last Name", ""),
new EntryElement("Email", "Email", "") { KeyboardType = UIKeyboardType.EmailAddress },
new DateElement("Event Date", DateTime.Now),
new RootElement ("Type of Shoot", new RadioGroup (0)){
new Section (){
new RadioElement("Wedding"),
new RadioElement("Portrait"),
new RadioElement("Boudoir"),
new RadioElement("Other")
}
} ,
new EntryElement("Message", "Message", "")
} ,
new Section () {
new StringElement("Send", delegate { BookASession.SendMessage(); } )
}
};
}
The problem with the value properties not getting updated can be solved by calling the method ResignFirstResponder on the element that has focus. I guess this is something iOS specific.
The way i like to accomplish this is by keeping references to my input elements. This way i can easily fetch their input values without having to search through the entire element tree. I'm doing so by encapsulating the creation logic for a particular screen in a separate clase, like this:
Also, you may want to decouple the form processing logic by having the class expose an event, like this:
1 - Create a class that will hold the event data, extending EventArgs:
2 - Declare your event in BookASessionScreen:
3 - Fire the event in your delegate