0

我创建了一个 RadioGroup:

Root = new RootElement ("Club 1") {
            new Section ("Club Members"){
                new StringElement ("P1", "Kyle"),
                new StringElement ("P2", "Matt"),
                new RootElement("Members", new RadioGroup(0))
                {
                    CreateRoot()
                }

            }

上面的 RootElement 需要显示从 RadioGroup 中选择的值。

RootElement CreateRoot ()
    {
        StringElement se = new StringElement (String.Empty);
        MyRadioElement.OnSelected += delegate(object sender, EventArgs e) {
            se.Caption = (sender as MyRadioElement).Caption;
            var root = se.GetImmediateRootElement ();
            root.Reload (se, UITableViewRowAnimation.Fade);
        };
        return new RootElement (String.Empty, new RadioGroup (0)) {
            new Section ("Select Member") {
                new MyRadioElement ("No Member Selected"),
                new MyRadioElement ("Member 1"),
                new MyRadioElement ("Member 2"),
                new MyRadioElement ("Member 3")
            }
        };
    }

我有一个外部课程:

class MyRadioElement : RadioElement {
    public MyRadioElement (string s) : base (s) {}

    public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
    {
        base.Selected (dvc, tableView, path);
        var selected = OnSelected;
        if (selected != null)
            selected (this, EventArgs.Empty);
    }

    static public event EventHandler<EventArgs> OnSelected;
}

如何让选定的值重新显示在父根元素上?

4

1 回答 1

0

我没有停用控制器。

类 MyRadioElement : RadioElement { public MyRadioElement (string s) : base (s) {}

public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
    base.Selected (dvc, tableView, path);
    var selected = OnSelected;
    if (selected != null)
        selected (this, EventArgs.Empty);

    dvc.DeactivateController(true);
}

static public event EventHandler<EventArgs> OnSelected;

}

于 2012-10-20T16:12:44.693 回答