On Fri, Oct 7, 2011 at 13:11, [email protected] <[email protected]> wrote:
> Hi Guido, if you just try to remove the using block for the alert?
> I had the same problem and it was solved in this way.
Well, removing the 'using' clause fixed the problem:

button.Clicked += delegate {
    var alert = new UIAlertView {Title = "alert", Message = "message" };
    alert.AddButton("yes");
    alert.AddButton("no");
    alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
        if (e.ButtonIndex == 0) {
            label.Text = "we got a 'yes'";
        }
        else
        {
            label.Text = "too bad...";
        }
    };
    alert.Show();
};

I must confess that I do not really see the difference with the original:

button.Clicked += delegate {
    using (var alert = new UIAlertView {Title = "alert", Message =
"message" }) {
        alert.AddButton("yes");
        alert.AddButton("no");
        alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
            if (e.ButtonIndex == 0) {
                label.Text = "we got a 'yes'";
            } else {
                label.Text = "too bad...";
            }
        };
        alert.Show();
    }
};

Isn't the variable 'alert' a local temporary variable in both cases?

Well, anyway, my problem is fixed.

Thanx for the help,


Guido.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to