【问题标题】:Monotouch.dialog EntryElement not being updated after editingMonotouch.dialog EntryElement 编辑后未更新
【发布时间】:2012-01-18 06:23:05
【问题描述】:

我正在使用此代码来创建对话框:

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

这是 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;
 }
}

问题是上述属性总是返回旧值,它永远不会更新。 知道为什么吗?

谢谢, 伊格纳西奥

【问题讨论】:

    标签: xamarin.ios monotouch.dialog


    【解决方案1】:

    我找到了我的问题的答案,这个帖子有它的关键

    How can I pass data into MonoTouch.Dialog's delegates?

    这一行: 在尝试检索它之前,我可以通过调用 field.FetchValue() 来绕过它

    所以我将属性修改为

    public string VendorId {
    get {
       idElement.FetchValue();
       return idElement.Value;
     }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-16
      • 2012-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多