单点触控对话框获取委托中的元素值



我有一个从动态对象创建的根元素。我想在点击元素时获取对象 Id:

var section = new Section("","Select a complex and then a property");
var root = new RootElement("Complexes"){section};
foreach(Complex complex in complexes){
    var line = new RootElement(complex.Name);
    foreach(Property property in complex.Properties){
        line.Add(new Section(property.Name,"Select the property to work"){
            new StringElement(property.Description, delegate {
                // NEED HELP HERE!!! here I want to get property.Id
            })
        });
    }
    section.Add(line);
}
this.Root = root;

有什么线索吗?多谢。

复制属性。Id 在局部变量中使用并在委托中使用

var line = new RootElement(complex.Name);
foreach(Property property in complex.Properties){
    var propertyId = property.Id;
    line.Add(new Section(property.Name,"Select the property to work"){
        new StringElement(property.Description, delegate {
            (new UIAlertView("title", "Id - " + propertyId, null, "Ok")).Show();
        })
    });
}
section.Add(line);

最新更新