Reputation: 245
I'm using this code to create the dialog:
SettingsDialog settingDialog = new SettingsDialog ();
RootElement dialog = settingDialog.CreateDialog ();
DialogViewController dv = new DialogViewController (dialog, true);
dv.ViewDissapearing += delegate(object sender1, EventArgs e1) {
// update the values
Config.VendorId = settingDialog.VendorId;
} ;
NavigationController.PushViewController (dv, true);
Ths is the code for the SettingsDialogClass
public class SettingsDialog
{
private EntryElement idElement;
public RootElement CreateDialog ()
{
idElement = new EntryElement ("Vendor Id", string.Empty, Config.VendorId.ToString (CultureInfo.InvariantCulture)){ KeyboardType = UIKeyboardType.NumberPad };
element = new RootElement ("Configuration"){
new Section (){
idElement
} ,
...
}
public string VendorId {
get {
return idElement.Value;
}
}
The problem is that the above property ALWAYS returns the old value, it never gets updated. Any idea why?
Thank, Ignacio
Upvotes: 2
Views: 770
Reputation: 245
I found the answer to my question, this thread had the key to it
How can I pass data into MonoTouch.Dialog's delegates?
this line: i was able to get around it by calling field.FetchValue() before trying to retrieve it
So I modified the property as
public string VendorId {
get {
idElement.FetchValue();
return idElement.Value;
}
}
Upvotes: 2